[llvm] [ConstraintElim] Decompose shl nsw for signed predicates (PR #76961)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 14:37:30 PST 2024


================
@@ -517,6 +517,17 @@ static Decomposition decompose(Value *V,
       return Result;
     }
 
+    // shl nsw x, shift is mul nsw x, (1<<shift),
+    // with the exception of shift == bw-1.
+    if (match(V, m_NSWShl(m_Value(Op0), m_ConstantInt(CI)))) {
+      uint64_t Shift = CI->getValue().getLimitedValue();
+      if (Shift < Ty->getIntegerBitWidth() - 1 && Shift < 64) {
----------------
fhahn wrote:

Sounds good!

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


More information about the llvm-commits mailing list