[llvm] [SimplifyCFG] Skip threading if the target may have divergent branches (PR #100185)
Sameer Sahasrabuddhe via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 23:53:30 PDT 2024
================
@@ -3246,7 +3246,12 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
}
/// Return true if we can thread a branch across this block.
-static bool BlockIsSimpleEnoughToThreadThrough(BasicBlock *BB) {
+static bool BlockIsSimpleEnoughToThreadThrough(BasicBlock *BB,
+ const TargetTransformInfo &TTI) {
+ // Skip threading if the branch may be divergent.
+ if (TTI.hasBranchDivergence(BB->getParent()))
----------------
ssahasra wrote:
The TTI check has nothing to do with the specific block `BB`. A more natural check for this seems to be the outer function `FoldCondBranchOnValueKnownInPredecessor()`, where it can be an early return even before entering the `do-while` loop.
https://github.com/llvm/llvm-project/pull/100185
More information about the llvm-commits
mailing list