[llvm] [LICM] Fold associative binary ops to promote code hoisting (PR #81608)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 04:30:02 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 718ba5a58452f013f40fab94f967064919bf13ff 9a4590cf763b336e77fd969a78c449a0b77e8f42 -- llvm/lib/Transforms/Scalar/LICM.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 04b4878f52..4b7a772ae9 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -2817,8 +2817,8 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
     IRBuilder<> Builder(Preheader->getTerminator());
     Value *Inv = Builder.CreateBinOp(Opcode, C1, C2, "invariant.op");
 
-    auto *NewBO = BinaryOperator::Create(Opcode, LV, Inv,
-                                         BO->getName() + ".reass", BO);
+    auto *NewBO =
+        BinaryOperator::Create(Opcode, LV, Inv, BO->getName() + ".reass", BO);
     NewBO->copyIRFlags(BO);
     BO->replaceAllUsesWith(NewBO);
     eraseInstruction(*BO, SafetyInfo, MSSAU);

``````````

</details>


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


More information about the llvm-commits mailing list