[llvm] [IR] Add `samesign` flag to icmp instruction (PR #111419)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 05:25:20 PDT 2024


================
@@ -1033,6 +1033,28 @@ class CmpInst : public Instruction {
   }
 };
 
+/// An icmp instruction, which can be marked as "samesign", indicating that the
+/// two operands have the same sign. This means that we can convert "slt/ult"
+/// to "ult", which enables more optimizations.
+class PossiblySameSignInst : public CmpInst {
----------------
nikic wrote:

ICmpInst is the only instruction that supports the flag, so adding the methods directly there will reduce the amount of casting that has to be done.

Similar to how nuw/nsw are directly set on TruncInst.

https://github.com/llvm/llvm-project/pull/111419


More information about the llvm-commits mailing list