[llvm] [InstCombine] Resolve TODO: Remove one-time check if other logic operand (Y) is constant (PR #77973)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 11:21:27 PST 2024
================
@@ -368,12 +368,17 @@ 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());
- return match(V,
- m_OneUse(m_BinOp(ShiftOpcode, m_Value(X), m_Constant(C0)))) &&
+ bool matchFirst;
+ if (match(W, m_ImmConstant()))
+ matchFirst = match(V, (m_BinOp(ShiftOpcode, m_Value(X), m_Constant(C0))));
+ else
+ matchFirst =
+ match(V, m_OneUse(m_BinOp(ShiftOpcode, m_Value(X), m_Constant(C0))));
+
+ return matchFirst &&
----------------
nikic wrote:
Not done.
https://github.com/llvm/llvm-project/pull/77973
More information about the llvm-commits
mailing list