[llvm] [SimplifyCFG] Speculatively execute empty BBs with multiple predecessors (PR #120905)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 23 06:41:11 PST 2024
================
@@ -3506,6 +3506,96 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
return true;
}
+/// Speculate a conditional basic block flattening the CFG.
+/// Compared to speculativelyExecuteBB, it allows \p ThenBB to have multiple
+/// predecessors other than the current BB. An illustration of this transform is
+/// turning this IR:
+/// \code
+/// BB:
+/// %cmp = icmp ult %x, %y
+/// br i1 %cmp, label %EndBB, label %ThenBB
+/// ThenBB:
+/// br label BB2
+/// EndBB:
+/// %phi = phi i1 [ true, %ThenBB ], [ false, %BB ], [ false, %OtherBB ]
+/// ...
+/// \endcode
+///
+/// Into this IR:
+/// \code
+/// BB:
+/// %cmp = icmp ult %x, %y
+/// %sel = select i1 %cmp, i1 true, i1 false
+/// br label %EndBB
+/// ThenBB:
+/// br label BB2
----------------
antoniofrighetto wrote:
Above as well.
```suggestion
/// br label %EndBB
```
https://github.com/llvm/llvm-project/pull/120905
More information about the llvm-commits
mailing list