[llvm] [JumpThreading][Local] Redirect other phi values from BB to Succ except commom preds (PR #166390)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 07:54:19 PST 2025
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 origin/main HEAD --extensions cpp -- llvm/lib/Transforms/Scalar/JumpThreading.cpp llvm/lib/Transforms/Utils/Local.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index d2fa42275..683fc4015 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -2397,8 +2397,8 @@ void JumpThreadingPass::threadEdge(BasicBlock *BB,
// And finally, do it!
LLVM_DEBUG(dbgs() << " Threading edge from '" << PredBB->getName()
- << "' to '" << SuccBB->getName()
- << "', across block:\n " << *BB << "\n");
+ << "' to '" << SuccBB->getName() << "', across block:\n "
+ << *BB << "\n");
LVI->threadEdge(PredBB, BB, SuccBB);
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 86b78d4e9..2b441300c 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1112,9 +1112,9 @@ static void redirectValuesFromPredecessorsToPhi(
}
if (CommonPreds.size() == 1) {
// Single common predecessor, fold the phi node into Succ.
- PN->addIncoming(OldValPN->getIncomingValueForBlock(*CommonPreds.begin()), BB);
- }
- else if (CommonPreds.size() >= 2) {
+ PN->addIncoming(OldValPN->getIncomingValueForBlock(*CommonPreds.begin()),
+ BB);
+ } else if (CommonPreds.size() >= 2) {
// >1 common predecessors, reserve the phi in BB.
PN->addIncoming(OldVal, BB);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/166390
More information about the llvm-commits
mailing list