[llvm-branch-commits] [llvm] 256a035 - [NFC][SimplifyCFG] FoldBranchToCommonDest(): unclutter Cond/CondInPred handling

Roman Lebedev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 22 06:29:33 PST 2021


Author: Roman Lebedev
Date: 2021-01-22T17:23:11+03:00
New Revision: 256a0357524b6cea3c705a77ec3d3c0122ede861

URL: https://github.com/llvm/llvm-project/commit/256a0357524b6cea3c705a77ec3d3c0122ede861
DIFF: https://github.com/llvm/llvm-project/commit/256a0357524b6cea3c705a77ec3d3c0122ede861.diff

LOG: [NFC][SimplifyCFG] FoldBranchToCommonDest(): unclutter Cond/CondInPred handling

We don't need those variables, we can just get the final value directly.

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 5ca8a0b33176..d1d687c721fb 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2934,16 +2934,12 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
     // Note that there may be multiple predecessor blocks, so we cannot move
     // bonus instructions to a predecessor block.
     ValueToValueMapTy VMap; // maps original values to cloned values
-    Instruction *CondInPred;
     for (Instruction &BonusInst : *BB) {
       if (isa<DbgInfoIntrinsic>(BonusInst) || isa<BranchInst>(BonusInst))
         continue;
 
       Instruction *NewBonusInst = BonusInst.clone();
 
-      if (&BonusInst == Cond)
-        CondInPred = NewBonusInst;
-
       if (PBI->getDebugLoc() != NewBonusInst->getDebugLoc()) {
         // Unless the instruction has the same !dbg location as the original
         // branch, drop it. When we fold the bonus instructions we want to make
@@ -3004,8 +3000,8 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU,
 
     // Now that the Cond was cloned into the predecessor basic block,
     // or/and the two conditions together.
-    Instruction *NewCond = cast<Instruction>(
-        Builder.CreateBinOp(Opc, PBI->getCondition(), CondInPred, "or.cond"));
+    Instruction *NewCond = cast<Instruction>(Builder.CreateBinOp(
+        Opc, PBI->getCondition(), VMap[BI->getCondition()], "or.cond"));
     PBI->setCondition(NewCond);
 
     uint64_t PredTrueWeight, PredFalseWeight, SuccTrueWeight, SuccFalseWeight;


        


More information about the llvm-branch-commits mailing list