[llvm] [LICM] Prevent fold and hoist of binary ops with over 2 uses (PR #102114)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 02:20:02 PDT 2024


================
@@ -2806,7 +2806,8 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
     return false;
 
   auto *BO0 = dyn_cast<BinaryOperator>(BO->getOperand(0));
-  if (!BO0 || BO0->getOpcode() != Opcode || !BO0->isAssociative())
+  if (!BO0 || BO0->getOpcode() != Opcode || !BO0->isAssociative() ||
+      BO0->getNumUses() > 2)
----------------
nikic wrote:

```suggestion
      BO0->hasNUsesOrMore(3))
```
Early exit use list scan.

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


More information about the llvm-commits mailing list