[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
Mon Jan 22 01:55:17 PST 2024


================
@@ -366,14 +366,14 @@ static Instruction *foldShiftOfShiftedBinOp(BinaryOperator &I,
 
   Type *Ty = I.getType();
 
-  // Find a matching one-use shift by constant. The fold is not valid if the sum
+  // Find a matching 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) {
-    APInt Threshold(Ty->getScalarSizeInBits(), Ty->getScalarSizeInBits());
-    return match(V,
-                 m_OneUse(m_BinOp(ShiftOpcode, m_Value(X), m_Constant(C0)))) &&
+  auto matchFirstShift = [&](Value *V, Value *W) {
+    unsigned size = Ty->getScalarSizeInBits();
+    APInt Threshold(size, size);
----------------
nikic wrote:

```suggestion
    unsigned Size = Ty->getScalarSizeInBits();
    APInt Threshold(Size, Size);
```
Coding style requires upper-case variable names.

https://github.com/llvm/llvm-project/pull/77973


More information about the llvm-commits mailing list