[llvm] [InstCombine] Fold (X / C) < X and (X >> C) < X into X > 0 (PR #85555)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 17 12:21:50 PDT 2024
================
@@ -7406,6 +7406,31 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
if (Instruction *Res = foldReductionIdiom(I, Builder, DL))
return Res;
+ // Folding (X / Y) < X => X > 0 for some constant Y other than 0 or 1
+ {
+ Constant *Divisor;
+ Value *Dividend;
+ if (match(Op0,
+ m_CombineOr(m_SDiv(m_Value(Dividend), m_ImmConstant(Divisor)),
+ m_UDiv(m_Value(Dividend), m_ImmConstant(Divisor)))) &&
+ match(Op1, m_Deferred(Dividend)) &&
+ !(Divisor->isZeroValue() || Divisor->isOneValue())) {
----------------
goldsteinn wrote:
This is buggy I think. Imagine a non-splat vec with denom `<i8 0, i8 123>`. Not zero/ones but still incorrect. Think you should change `m_ImmConstant` to `m_APInt` then just use `ugt(1)`
https://github.com/llvm/llvm-project/pull/85555
More information about the llvm-commits
mailing list