Skip to content

Commit 256a035

Browse files
committed
[NFC][SimplifyCFG] FoldBranchToCommonDest(): unclutter Cond/CondInPred handling
We don't need those variables, we can just get the final value directly.
1 parent aabed37 commit 256a035

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,16 +2934,12 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
29342934
// Note that there may be multiple predecessor blocks, so we cannot move
29352935
// bonus instructions to a predecessor block.
29362936
ValueToValueMapTy VMap; // maps original values to cloned values
2937-
Instruction *CondInPred;
29382937
for (Instruction &BonusInst : *BB) {
29392938
if (isa<DbgInfoIntrinsic>(BonusInst) || isa<BranchInst>(BonusInst))
29402939
continue;
29412940

29422941
Instruction *NewBonusInst = BonusInst.clone();
29432942

2944-
if (&BonusInst == Cond)
2945-
CondInPred = NewBonusInst;
2946-
29472943
if (PBI->getDebugLoc() != NewBonusInst->getDebugLoc()) {
29482944
// Unless the instruction has the same !dbg location as the original
29492945
// branch, drop it. When we fold the bonus instructions we want to make
@@ -3004,8 +3000,8 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
30043000

30053001
// Now that the Cond was cloned into the predecessor basic block,
30063002
// or/and the two conditions together.
3007-
Instruction *NewCond = cast<Instruction>(
3008-
Builder.CreateBinOp(Opc, PBI->getCondition(), CondInPred, "or.cond"));
3003+
Instruction *NewCond = cast<Instruction>(Builder.CreateBinOp(
3004+
Opc, PBI->getCondition(), VMap[BI->getCondition()], "or.cond"));
30093005
PBI->setCondition(NewCond);
30103006

30113007
uint64_t PredTrueWeight, PredFalseWeight, SuccTrueWeight, SuccFalseWeight;

0 commit comments

Comments
 (0)