[llvm] [SimplifyCFG] Removed the conditional branch (PR #146445)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 20:50:28 PDT 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 HEAD~1 HEAD --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 fb54b854c..5c5ba9b12 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3448,13 +3448,13 @@ static ConstantInt *getKnownValueOnEdge(Value *V, BasicBlock *From,
   auto *BI = dyn_cast<BranchInst>(From->getTerminator());
   if (BI && BI->isConditional() && BI->getCondition() == V &&
       BI->getSuccessor(0) != BI->getSuccessor(1)) {
-    ConstantInt *KnownValue = 
-              BI->getSuccessor(0) == To ? ConstantInt::getTrue(BI->getContext())
-                                        : ConstantInt::getFalse(BI->getContext());
+    ConstantInt *KnownValue = BI->getSuccessor(0) == To
+                                  ? ConstantInt::getTrue(BI->getContext())
+                                  : ConstantInt::getFalse(BI->getContext());
     if (Strong) {
       Value *Cond = BI->getCondition();
       Instruction *CondInst = dyn_cast<Instruction>(Cond);
-      return (CondInst && CondInst->getParent() == From) ? KnownValue : nullptr; 
+      return (CondInst && CondInst->getParent() == From) ? KnownValue : nullptr;
     } else {
       return KnownValue;
     }
@@ -3607,11 +3607,12 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
     BranchInst *EdgeBI = cast<BranchInst>(EdgeBB->getTerminator());
     EdgeBI->setSuccessor(0, RealDest);
     EdgeBI->setDebugLoc(BI->getDebugLoc());
-    
+
     bool RemoveCondBr = StronglyKnownValues.count(CB);
     if (RemoveCondBr) {
       RealDest->removePredecessor(BB);
-      ReplaceInstWithInst(BI, BranchInst::Create(BI->getSuccessor(CB->getZExtValue())));
+      ReplaceInstWithInst(
+          BI, BranchInst::Create(BI->getSuccessor(CB->getZExtValue())));
     }
 
     if (DTU) {
@@ -3632,7 +3633,7 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
 
     // If we remove the conditional branch, cannot keep simplifying.
     if (RemoveCondBr) {
-      return true; 
+      return true;
     }
 
     // Signal repeat, simplifying any other constants.

``````````

</details>


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


More information about the llvm-commits mailing list