[llvm] Fold (a % b) lt/ge (b-1) where b is a power of 2 (PR #72504)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 04:06:12 PST 2023


================
@@ -6837,6 +6837,35 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
     Changed = true;
   }
 
+  {
+    Value *X;
+    const APInt *C, *CC;
+    ICmpInst::Predicate Pred = I.getPredicate();
+    if (match(Op1, m_SRem(m_Value(X), m_Power2(C))) &&
+        match(Op0, m_APInt(CC))) {
----------------
nikic wrote:

This check makes no sense, constant is canonicalized to RHS.

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


More information about the llvm-commits mailing list