@@ -3246,12 +3246,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
32463246}
32473247
32483248// / Return true if we can thread a branch across this block.
3249- static bool BlockIsSimpleEnoughToThreadThrough (BasicBlock *BB,
3250- const TargetTransformInfo &TTI) {
3251- // Skip threading if the branch may be divergent.
3252- if (TTI.hasBranchDivergence (BB->getParent ()))
3253- return false ;
3254-
3249+ static bool BlockIsSimpleEnoughToThreadThrough (BasicBlock *BB) {
32553250 int Size = 0 ;
32563251 EphemeralValueTracker EphTracker;
32573252
@@ -3306,9 +3301,10 @@ static ConstantInt *getKnownValueOnEdge(Value *V, BasicBlock *From,
33063301// / If we have a conditional branch on something for which we know the constant
33073302// / value in predecessors (e.g. a phi node in the current block), thread edges
33083303// / from the predecessor to their ultimate destination.
3309- static std::optional<bool > FoldCondBranchOnValueKnownInPredecessorImpl (
3310- BranchInst *BI, DomTreeUpdater *DTU, const DataLayout &DL,
3311- const TargetTransformInfo &TTI, AssumptionCache *AC) {
3304+ static std::optional<bool >
3305+ FoldCondBranchOnValueKnownInPredecessorImpl (BranchInst *BI, DomTreeUpdater *DTU,
3306+ const DataLayout &DL,
3307+ AssumptionCache *AC) {
33123308 SmallMapVector<ConstantInt *, SmallSetVector<BasicBlock *, 2 >, 2 > KnownValues;
33133309 BasicBlock *BB = BI->getParent ();
33143310 Value *Cond = BI->getCondition ();
@@ -3336,7 +3332,7 @@ static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl(
33363332 // Now we know that this block has multiple preds and two succs.
33373333 // Check that the block is small enough and values defined in the block are
33383334 // not used outside of it.
3339- if (!BlockIsSimpleEnoughToThreadThrough (BB, TTI ))
3335+ if (!BlockIsSimpleEnoughToThreadThrough (BB))
33403336 return false ;
33413337
33423338 for (const auto &Pair : KnownValues) {
@@ -3463,14 +3459,15 @@ static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl(
34633459 return false ;
34643460}
34653461
3466- static bool FoldCondBranchOnValueKnownInPredecessor (
3467- BranchInst *BI, DomTreeUpdater *DTU, const DataLayout &DL,
3468- const TargetTransformInfo &TTI, AssumptionCache *AC) {
3462+ static bool FoldCondBranchOnValueKnownInPredecessor (BranchInst *BI,
3463+ DomTreeUpdater *DTU,
3464+ const DataLayout &DL,
3465+ AssumptionCache *AC) {
34693466 std::optional<bool > Result;
34703467 bool EverChanged = false ;
34713468 do {
34723469 // Note that None means "we changed things, but recurse further."
3473- Result = FoldCondBranchOnValueKnownInPredecessorImpl (BI, DTU, DL, TTI, AC);
3470+ Result = FoldCondBranchOnValueKnownInPredecessorImpl (BI, DTU, DL, AC);
34743471 EverChanged |= Result == std::nullopt || *Result;
34753472 } while (Result == std::nullopt );
34763473 return EverChanged;
@@ -7546,7 +7543,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
75467543 // If this is a branch on something for which we know the constant value in
75477544 // predecessors (e.g. a phi node in the current block), thread control
75487545 // through this block.
7549- if (FoldCondBranchOnValueKnownInPredecessor (BI, DTU, DL, TTI, Options.AC ))
7546+ if (FoldCondBranchOnValueKnownInPredecessor (BI, DTU, DL, Options.AC ))
75507547 return requestResimplify ();
75517548
75527549 // Scan predecessor blocks for conditional branches.
0 commit comments