[llvm] Implement foldICmpRemConstant in InstCombineCompares (PR #77410)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 23:24:19 PST 2024
================
@@ -2572,6 +2572,46 @@ Instruction *InstCombinerImpl::foldICmpSRemConstant(ICmpInst &Cmp,
return new ICmpInst(ICmpInst::ICMP_UGT, And, ConstantInt::get(Ty, SignMask));
}
+Instruction *InstCombinerImpl::foldICmpRemConstant(ICmpInst &Cmp,
+ BinaryOperator *Rem,
+ const APInt &C) {
+ const ICmpInst::Predicate Pred = Cmp.getPredicate();
+ Value *X = Rem->getOperand(0);
----------------
dtcxzyw wrote:
```suggestion
if (!ICmpInst::isEquality(Pred) || !C.isZero())
return nullptr;
Value *X = Rem->getOperand(0);
```
It only holds for `==/!= 0`.
https://github.com/llvm/llvm-project/pull/77410
More information about the llvm-commits
mailing list