[llvm] [InstCombine] Resolve TODO: Remove one-time check if other logic operand (Y) is constant (PR #77973)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 13 11:40:54 PST 2024
================
@@ -368,10 +368,14 @@ static Instruction *foldShiftOfShiftedBinOp(BinaryOperator &I,
// Find a matching one-use shift by constant. The fold is not valid if the sum
// of the shift values equals or exceeds bitwidth.
- // TODO: Remove the one-use check if the other logic operand (Y) is constant.
Value *X, *Y;
- auto matchFirstShift = [&](Value *V) {
+ auto matchFirstShift = [&](Value *V, Value *W) {
APInt Threshold(Ty->getScalarSizeInBits(), Ty->getScalarSizeInBits());
+ if (isa<Constant>(W)) {
+ return match(V, (m_BinOp(ShiftOpcode, m_Value(X), m_Constant(C0)))) &&
+ match(ConstantExpr::getAdd(C0, C1),
+ m_SpecificInt_ICMP(ICmpInst::ICMP_ULT, Threshold));
+ }
----------------
AtariDreams wrote:
Done!
https://github.com/llvm/llvm-project/pull/77973
More information about the llvm-commits
mailing list