[llvm] [InstCombine] fold icmp of select with invertible shl (PR #147182)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 08:18:11 PDT 2025


================
@@ -5892,6 +5892,12 @@ static void collectOffsetOp(Value *V, SmallVectorImpl<OffsetOp> &Offsets,
     Offsets.emplace_back(Instruction::Xor, Inst->getOperand(1));
     Offsets.emplace_back(Instruction::Xor, Inst->getOperand(0));
     break;
+  case Instruction::Shl:
+    if (match(Inst, m_NSWShl(m_Value(), m_Value())))
+      Offsets.emplace_back(Instruction::AShr, Inst->getOperand(1));
+    if (match(Inst, m_NUWShl(m_Value(), m_Value())))
----------------
nikic wrote:

```suggestion
    if (Inst->hasNoUnsignedWrap())
```

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


More information about the llvm-commits mailing list