summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp11
-rw-r--r--test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll18
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index efd17650f2..39163e4050 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1046,15 +1046,8 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) {
return false;
}
- // If we get here, we can hoist the instruction. Try to place it before the
- // icmp instruction preceeding the conditional branch.
- BasicBlock::iterator InsertPos = BI;
- if (InsertPos != BIParent->begin())
- --InsertPos;
- if (InsertPos == BrCond && !isa<PHINode>(BrCond))
- BIParent->getInstList().splice(InsertPos, BB1->getInstList(), I);
- else
- BIParent->getInstList().splice(BI, BB1->getInstList(), I);
+ // If we get here, we can hoist the instruction.
+ BIParent->getInstList().splice(BI, BB1->getInstList(), I);
// Create a select whose true value is the speculatively executed value and
// false value is the previously determined FalseV.
diff --git a/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll b/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll
new file mode 100644
index 0000000000..b2d671da67
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -simplifycfg -disable-output
+; PR 2800
+
+define void @foo() {
+start:
+ %tmp = call i1 @bar( ) ; <i1> [#uses=4]
+ br i1 %tmp, label %brtrue, label %brfalse
+
+brtrue: ; preds = %start
+ %tmpnew = and i1 %tmp, %tmp ; <i1> [#uses=1]
+ br label %brfalse
+
+brfalse: ; preds = %brtrue, %start
+ %andandtmp.0 = phi i1 [ %tmp, %start ], [ %tmpnew, %brtrue ] ; <i1> [#uses=0]
+ ret void
+}
+
+declare i1 @bar()