diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 1a17524..f23e288 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3246,12 +3246,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, } /// Return true if we can thread a branch across this block. -static bool BlockIsSimpleEnoughToThreadThrough(BasicBlock *BB, - const TargetTransformInfo &TTI) { - // Skip threading if the branch may be divergent. - if (TTI.hasBranchDivergence(BB->getParent())) - return false; - +static bool BlockIsSimpleEnoughToThreadThrough(BasicBlock *BB) { int Size = 0; EphemeralValueTracker EphTracker; @@ -3306,9 +3301,10 @@ static ConstantInt *getKnownValueOnEdge(Value *V, BasicBlock *From, /// If we have a conditional branch on something for which we know the constant /// value in predecessors (e.g. a phi node in the current block), thread edges /// from the predecessor to their ultimate destination. -static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl( - BranchInst *BI, DomTreeUpdater *DTU, const DataLayout &DL, - const TargetTransformInfo &TTI, AssumptionCache *AC) { +static std::optional<bool> +FoldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU, + const DataLayout &DL, + AssumptionCache *AC) { SmallMapVector<ConstantInt *, SmallSetVector<BasicBlock *, 2>, 2> KnownValues; BasicBlock *BB = BI->getParent(); Value *Cond = BI->getCondition(); @@ -3336,7 +3332,7 @@ static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl( // Now we know that this block has multiple preds and two succs. // Check that the block is small enough and values defined in the block are // not used outside of it. - if (!BlockIsSimpleEnoughToThreadThrough(BB, TTI)) + if (!BlockIsSimpleEnoughToThreadThrough(BB)) return false; for (const auto &Pair : KnownValues) { @@ -3463,14 +3459,15 @@ static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl( return false; } -static bool FoldCondBranchOnValueKnownInPredecessor( - BranchInst *BI, DomTreeUpdater *DTU, const DataLayout &DL, - const TargetTransformInfo &TTI, AssumptionCache *AC) { +static bool FoldCondBranchOnValueKnownInPredecessor(BranchInst *BI, + DomTreeUpdater *DTU, + const DataLayout &DL, + AssumptionCache *AC) { std::optional<bool> Result; bool EverChanged = false; do { // Note that None means "we changed things, but recurse further." - Result = FoldCondBranchOnValueKnownInPredecessorImpl(BI, DTU, DL, TTI, AC); + Result = FoldCondBranchOnValueKnownInPredecessorImpl(BI, DTU, DL, AC); EverChanged |= Result == std::nullopt || *Result; } while (Result == std::nullopt); return EverChanged; @@ -7546,7 +7543,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) { // If this is a branch on something for which we know the constant value in // predecessors (e.g. a phi node in the current block), thread control // through this block. - if (FoldCondBranchOnValueKnownInPredecessor(BI, DTU, DL, TTI, Options.AC)) + if (FoldCondBranchOnValueKnownInPredecessor(BI, DTU, DL, Options.AC)) return requestResimplify(); // Scan predecessor blocks for conditional branches. |