@@ -3246,12 +3246,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
3246
3246
}
3247
3247
3248
3248
// / 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) {
3255
3250
int Size = 0 ;
3256
3251
EphemeralValueTracker EphTracker;
3257
3252
@@ -3306,9 +3301,10 @@ static ConstantInt *getKnownValueOnEdge(Value *V, BasicBlock *From,
3306
3301
// / If we have a conditional branch on something for which we know the constant
3307
3302
// / value in predecessors (e.g. a phi node in the current block), thread edges
3308
3303
// / 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) {
3312
3308
SmallMapVector<ConstantInt *, SmallSetVector<BasicBlock *, 2 >, 2 > KnownValues;
3313
3309
BasicBlock *BB = BI->getParent ();
3314
3310
Value *Cond = BI->getCondition ();
@@ -3336,7 +3332,7 @@ static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl(
3336
3332
// Now we know that this block has multiple preds and two succs.
3337
3333
// Check that the block is small enough and values defined in the block are
3338
3334
// not used outside of it.
3339
- if (!BlockIsSimpleEnoughToThreadThrough (BB, TTI ))
3335
+ if (!BlockIsSimpleEnoughToThreadThrough (BB))
3340
3336
return false ;
3341
3337
3342
3338
for (const auto &Pair : KnownValues) {
@@ -3463,14 +3459,15 @@ static std::optional<bool> FoldCondBranchOnValueKnownInPredecessorImpl(
3463
3459
return false ;
3464
3460
}
3465
3461
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) {
3469
3466
std::optional<bool > Result;
3470
3467
bool EverChanged = false ;
3471
3468
do {
3472
3469
// 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);
3474
3471
EverChanged |= Result == std::nullopt || *Result;
3475
3472
} while (Result == std::nullopt);
3476
3473
return EverChanged;
@@ -7546,7 +7543,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
7546
7543
// If this is a branch on something for which we know the constant value in
7547
7544
// predecessors (e.g. a phi node in the current block), thread control
7548
7545
// through this block.
7549
- if (FoldCondBranchOnValueKnownInPredecessor (BI, DTU, DL, TTI, Options.AC ))
7546
+ if (FoldCondBranchOnValueKnownInPredecessor (BI, DTU, DL, Options.AC ))
7550
7547
return requestResimplify ();
7551
7548
7552
7549
// Scan predecessor blocks for conditional branches.
0 commit comments