[llvm] [InstCombine] Add one-use limitation to box multiply fold (PR #72876)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 03:01:20 PST 2023


================
@@ -1405,8 +1405,13 @@ static Instruction *foldBoxMultiply(BinaryOperator &I) {
   // ResLo = (CrossSum << HalfBits) + (YLo * XLo)
   Value *XLo, *YLo;
   Value *CrossSum;
+  
+  // Checking the operands of I is used in no more than one place,
+  // which can not be deleted, cause a mul instruction has far more weight than
+  // add and shl instruction in IR, thus this method cannot achieve the goal of
+  // simplifying instructions, just return null.
----------------
nikic wrote:

```suggestion
  // Require one-use on the multiply to avoid increasing the number of
  // multiplications.
```

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


More information about the llvm-commits mailing list