[llvm] [EarlyIfConversion] Add cascading conditional branches as a conversion pattern (PR #218415)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 06:54:14 PDT 2026


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/CodeGen/EarlyIfConversion.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/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp
index 24fc9a90d..af2323a7c 100644
--- a/llvm/lib/CodeGen/EarlyIfConversion.cpp
+++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp
@@ -525,8 +525,8 @@ bool SSAIfConv::findInsertionPoint() {
 /// a potential candidate for if-conversion. Fill out the internal state.
 ///
 bool SSAIfConv::canConvertIf(MachineBasicBlock *MBB, bool Predicate,
-                              bool AllowMultiSuccTBB,
-                              MachineBasicBlock *ExplicitTail) {
+                             bool AllowMultiSuccTBB,
+                             MachineBasicBlock *ExplicitTail) {
   Head = MBB;
   TBB = FBB = Tail = nullptr;
 
@@ -768,7 +768,8 @@ CascadeResult SSAIfConv::matchCascade(MachineBasicBlock *MBB) {
       break;
 
     // Pred has 1 predecessor, so the cascade continues. If we've reached
-    // max depth, bail out entirely - we don't want to convert a partial cascade.
+    // max depth, bail out entirely - we don't want to convert a partial
+    // cascade.
     if (Blocks.size() > MaxCascadeDepth) {
       LLVM_DEBUG(dbgs() << "Cascade extends beyond max depth "
                         << MaxCascadeDepth << ", not converting.\n");
@@ -1432,13 +1433,12 @@ bool EarlyIfConverter::shouldConvertCascade(CascadeResult &Cascade,
   // Calculate CritLimit using cascade formula.
   unsigned CascadeSize = CascadeBlocks.size();
   unsigned MispredictPenalty = STI->getMispredictionPenalty();
-  unsigned CritLimit =
-      std::min(MispredictPenalty * 25 * CascadeSize / 100,
-               2 * MispredictPenalty);
+  unsigned CritLimit = std::min(MispredictPenalty * 25 * CascadeSize / 100,
+                                2 * MispredictPenalty);
 
   LLVM_DEBUG(dbgs() << "Cascade: size=" << CascadeSize
-                    << ", CritLimit=" << CritLimit << " (MispredictPenalty="
-                    << MispredictPenalty << ")\n");
+                    << ", CritLimit=" << CritLimit
+                    << " (MispredictPenalty=" << MispredictPenalty << ")\n");
 
   if (CritLimit == 0) {
     LLVM_DEBUG(dbgs() << "Cascade: CritLimit is 0, skipping\n");

``````````

</details>


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


More information about the llvm-commits mailing list