[llvm] c0f2c4c - [SimplifyCFG] remove unnecessary state variable; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 18 10:43:22 PDT 2021
Author: Sanjay Patel
Date: 2021-07-18T13:42:22-04:00
New Revision: c0f2c4ce10d296967f3e0f9a3fb53f49ab2eccd4
URL: https://github.com/llvm/llvm-project/commit/c0f2c4ce10d296967f3e0f9a3fb53f49ab2eccd4
DIFF: https://github.com/llvm/llvm-project/commit/c0f2c4ce10d296967f3e0f9a3fb53f49ab2eccd4.diff
LOG: [SimplifyCFG] remove unnecessary state variable; NFC
Keeping a marker for Changed might have made sense before
this code was refactored, but we never touch that variable
after initialization now.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index b2d21d3550e1..c0a31e3bdca9 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3192,9 +3192,6 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
return false;
BasicBlock *BB = BI->getParent();
-
- bool Changed = false;
-
TargetTransformInfo::TargetCostKind CostKind =
BB->getParent()->hasMinSize() ? TargetTransformInfo::TCK_CodeSize
: TargetTransformInfo::TCK_SizeAndLatency;
@@ -3203,20 +3200,20 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
if (!Cond || (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond)) ||
Cond->getParent() != BB || !Cond->hasOneUse())
- return Changed;
+ return false;
// Cond is known to be a compare or binary operator. Check to make sure that
// neither operand is a potentially-trapping constant expression.
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Cond->getOperand(0)))
if (CE->canTrap())
- return Changed;
+ return false;
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Cond->getOperand(1)))
if (CE->canTrap())
- return Changed;
+ return false;
// Finally, don't infinitely unroll conditional loops.
if (is_contained(successors(BB), BB))
- return Changed;
+ return false;
// With which predecessors will we want to deal with?
SmallVector<BasicBlock *, 8> Preds;
@@ -3257,7 +3254,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
// If there aren't any predecessors into which we can fold,
// don't bother checking the cost.
if (Preds.empty())
- return Changed;
+ return false;
// Only allow this transformation if computing the condition doesn't involve
// too many instructions and these involved instructions can be executed
@@ -3276,14 +3273,14 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
continue;
// I must be safe to execute unconditionally.
if (!isSafeToSpeculativelyExecute(&I))
- return Changed;
+ return false;
// Account for the cost of duplicating this instruction into each
// predecessor.
NumBonusInsts += PredCount;
// Early exits once we reach the limit.
if (NumBonusInsts > BonusInstThreshold)
- return Changed;
+ return false;
}
// Ok, we have the budget. Perform the transformation.
@@ -3291,7 +3288,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
auto *PBI = cast<BranchInst>(PredBlock->getTerminator());
return performBranchToCommonDestFolding(BI, PBI, DTU, MSSAU, TTI);
}
- return Changed;
+ return false;
}
// If there is only one store in BB1 and BB2, return it, otherwise return
More information about the llvm-commits
mailing list