[llvm] [SimplifyCFG] Check whether the previous condition is true before making assume (PR #105986)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 25 06:18:45 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: None (GkvJwa)
<details>
<summary>Changes</summary>
Fixes #<!-- -->105985
---
Full diff: https://github.com/llvm/llvm-project/pull/105986.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+9)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index da4d57f808e9bf..32f76cfc5818d3 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -7852,6 +7852,15 @@ static bool removeUndefIntroducingPredecessor(BasicBlock *BB,
Instruction *T = Predecessor->getTerminator();
IRBuilder<> Builder(T);
if (BranchInst *BI = dyn_cast<BranchInst>(T)) {
+ // Prevent multiple conditions cases
+ if (dyn_cast<CmpInst>(BI->getCondition()) &&
+ !pred_empty(Predecessor)) {
+ BranchInst *Pred_BI = dyn_cast<BranchInst>(
+ (*pred_begin(Predecessor))->getTerminator());
+ if (Pred_BI && dyn_cast<CmpInst>(BI->getCondition())) {
+ continue;
+ }
+ }
BB->removePredecessor(Predecessor);
// Turn unconditional branches into unreachables and remove the dead
// destination from conditional branches.
``````````
</details>
https://github.com/llvm/llvm-project/pull/105986
More information about the llvm-commits
mailing list