[llvm] [SimplifyCFG] Avoid introducing of too many phi nodes during sinking (PR #102465)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 06:35:50 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 1139dee910c45cfdd4a6066b22addef585e04032 5f7551b1066f26840126179dffde34f5c343b443 --extensions cpp -- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index c337e78c87..60cf208902 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1930,10 +1930,10 @@ static bool replacingOperandWithVariableIsCheap(const Instruction *I,
 // would be possible to sink them into their successor, creating one common
 // instruction instead. For every value that would be required to be provided by
 // PHI node (because an operand varies in each input block), add to PHIOperands.
-static bool canSinkInstructions(
-    ArrayRef<Instruction *> Insts,
-    DenseMap<const Use *, SmallVector<Value *, 4>> &PHIOperands,
-    SmallVectorImpl<int> &NeededPHIs) {
+static bool
+canSinkInstructions(ArrayRef<Instruction *> Insts,
+                    DenseMap<const Use *, SmallVector<Value *, 4>> &PHIOperands,
+                    SmallVectorImpl<int> &NeededPHIs) {
   // Prune out obviously bad instructions to move. Each instruction must have
   // the same number of uses, and we check later that the uses are consistent.
   std::optional<unsigned> NumUses;
@@ -2322,8 +2322,7 @@ static bool sinkCommonCodeFromPredecessors(BasicBlock *BB,
   // Number of new PHIs introduced if sinking the first N instructions.
   SmallVector<int> NeededPHIs;
   LockstepReverseIterator LRI(UnconditionalPreds);
-  while (LRI.isValid() &&
-         canSinkInstructions(*LRI, PHIOperands, NeededPHIs)) {
+  while (LRI.isValid() && canSinkInstructions(*LRI, PHIOperands, NeededPHIs)) {
     LLVM_DEBUG(dbgs() << "SINK: instruction can be sunk: " << *(*LRI)[0]
                       << "\n");
     ++ScanIdx;

``````````

</details>


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


More information about the llvm-commits mailing list