@@ -2934,16 +2934,12 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
2934
2934
// Note that there may be multiple predecessor blocks, so we cannot move
2935
2935
// bonus instructions to a predecessor block.
2936
2936
ValueToValueMapTy VMap; // maps original values to cloned values
2937
- Instruction *CondInPred;
2938
2937
for (Instruction &BonusInst : *BB) {
2939
2938
if (isa<DbgInfoIntrinsic>(BonusInst) || isa<BranchInst>(BonusInst))
2940
2939
continue ;
2941
2940
2942
2941
Instruction *NewBonusInst = BonusInst.clone ();
2943
2942
2944
- if (&BonusInst == Cond)
2945
- CondInPred = NewBonusInst;
2946
-
2947
2943
if (PBI->getDebugLoc () != NewBonusInst->getDebugLoc ()) {
2948
2944
// Unless the instruction has the same !dbg location as the original
2949
2945
// branch, drop it. When we fold the bonus instructions we want to make
@@ -3004,8 +3000,8 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
3004
3000
3005
3001
// Now that the Cond was cloned into the predecessor basic block,
3006
3002
// 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" ));
3009
3005
PBI->setCondition (NewCond);
3010
3006
3011
3007
uint64_t PredTrueWeight, PredFalseWeight, SuccTrueWeight, SuccFalseWeight;
0 commit comments