Adds fake conditional branches right after relaxed loads if necessary
[oota-llvm.git] / lib / CodeGen / BranchFolding.cpp
index df5cac5a9f7abb17a7fddd93cb64b39daf9145b4..e0b7d73339d700a27ed31d8d1bce75e4242b6f67 100644 (file)
@@ -1254,6 +1254,7 @@ ReoptimizeBlock:
       goto ReoptimizeBlock;
     }
 
+    /*
     // If the previous block unconditionally falls through to this block and
     // this block has no other predecessors, move the contents of this block
     // into the prior block. This doesn't usually happen when SimplifyCFG
@@ -1289,10 +1290,20 @@ ReoptimizeBlock:
       MadeChange = true;
       return MadeChange;
     }
+    */
 
     // If the previous branch *only* branches to *this* block (conditional or
     // not) remove the branch.
     if (PriorTBB == MBB && !PriorFBB) {
+      // XXX-disabled: Don't fold conditional branches that we added
+      // intentionally.
+      MachineBasicBlock::iterator I = PrevBB.getLastNonDebugInstr();
+      if (I != PrevBB.end()) {
+        if (I->isConditionalBranch()) {
+          return MadeChange ;
+        }
+      }
+
       TII->RemoveBranch(PrevBB);
       MadeChange = true;
       ++NumBranchOpts;