diff options
author | Nikita Popov <npopov@redhat.com> | 2023-10-30 09:04:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 09:04:04 +0100 |
commit | ed3f06b9b393cd51e78e5fbc7a46bce090c1817a (patch) | |
tree | 54b7960005e583b7cf5c65cbbcc5033a169270a1 /llvm/lib/AsmParser/LLLexer.cpp | |
parent | 41f3b83fb066b4c3273e9abe02a8630864f22f30 (diff) | |
download | llvm-ed3f06b9b393cd51e78e5fbc7a46bce090c1817a.zip llvm-ed3f06b9b393cd51e78e5fbc7a46bce090c1817a.tar.gz llvm-ed3f06b9b393cd51e78e5fbc7a46bce090c1817a.tar.bz2 |
[IR] Add zext nneg flag (#67982)
Add an nneg flag to the zext instruction, which specifies that the
argument is non-negative. Otherwise, the result is a poison value.
The primary use-case for the flag is to preserve information when sext
gets replaced with zext due to range-based canonicalization. The nneg
flag allows us to convert the zext back into an sext later. This is
useful for some optimizations (e.g. a signed icmp can fold with sext but
not zext), as well as some targets (e.g. RISCV prefers sext over zext).
Discourse thread: https://discourse.llvm.org/t/rfc-add-zext-nneg-flag/73914
This patch is based on https://reviews.llvm.org/D156444 by
@Panagiotis156, with some implementation simplifications and additional
tests.
---------
Co-authored-by: Panagiotis K <karouzakispan@gmail.com>
Diffstat (limited to 'llvm/lib/AsmParser/LLLexer.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index ae46209b..284a4c6 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -565,6 +565,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(nsw); KEYWORD(exact); KEYWORD(inbounds); + KEYWORD(nneg); KEYWORD(inrange); KEYWORD(addrspace); KEYWORD(section); |