[llvm] [InstCombine] Fold `(X * (Y << K)) u>> K -> X * Y` when highbits are not demanded (PR #111151)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 07:27:36 PDT 2024
================
@@ -770,6 +770,15 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
return InsertNewInstWith(Shl, I->getIterator());
}
}
+
+ const APInt *Factor;
+ if (match(I->getOperand(0),
+ m_OneUse(m_Mul(m_Value(X), m_APInt(Factor)))) &&
+ Factor->countr_zero() >= ShiftAmt) {
+ BinaryOperator *Mul = BinaryOperator::CreateMul(
----------------
goldsteinn wrote:
You can preserve `nuw` and `nsw` iff you have `nuw`:
https://alive2.llvm.org/ce/z/P9NudG
https://github.com/llvm/llvm-project/pull/111151
More information about the llvm-commits
mailing list