[llvm] [InstCombine] Fold (X / C) < X and (X >> C) < X into X > 0 (PR #85555)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 00:36:52 PDT 2024
================
@@ -7103,6 +7103,39 @@ Instruction *InstCombinerImpl::foldICmpCommutative(ICmpInst::Predicate Pred,
if (Value *V = foldICmpWithLowBitMaskedVal(Pred, Op0, Op1, Q, *this))
return replaceInstUsesWith(CxtI, V);
+ // Folding (X / Y) pred X => X ~pred 0 for some constant Y other than 0 or 1
----------------
nikic wrote:
nit: `~pred` looks like the inverse predicate, not the swapped predicate, which are different things. I'd write this either as
```suggestion
// Folding (X / Y) pred X => 0 pred X for some constant Y other than 0 or 1
```
or
```suggestion
// Folding (X / Y) pred X => X swap(pred) 0 for some constant Y other than 0 or 1
```
https://github.com/llvm/llvm-project/pull/85555
More information about the llvm-commits
mailing list