summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-09-21 21:18:19 +0000
committerDevang Patel <dpatel@apple.com>2007-09-21 21:18:19 +0000
commit3f65f02d25b920c3cef4dd8a8fc8fc76cad1236e (patch)
tree9bb1e2acf1c2a37e54253c12f7493b94aef662d3
parent4938d347723d452786c1a7c1d1b9ec79121b0040 (diff)
downloadllvm-3f65f02d25b920c3cef4dd8a8fc8fc76cad1236e.tar.gz
llvm-3f65f02d25b920c3cef4dd8a8fc8fc76cad1236e.tar.bz2
llvm-3f65f02d25b920c3cef4dd8a8fc8fc76cad1236e.tar.xz
Fix PR1692
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42209 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp8
-rw-r--r--test/Transforms/LoopIndexSplit/2007-09-21-LoopBound.ll63
2 files changed, 68 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 9e2f11bb6d..afb7339093 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -1181,15 +1181,17 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) {
// values in original loop's preheader.
// A_ExitValue = min(SplitValue, OrignalLoopExitValue)
// B_StartValue = max(SplitValue, OriginalLoopStartValue)
+ Instruction *InsertPt = L->getHeader()->getFirstNonPHI();
Value *C1 = new ICmpInst(Sign ?
ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
AEV,
ExitCondition->getOperand(ExitValueNum),
- "lsplit.ev", PHTerminator);
+ "lsplit.ev", InsertPt);
+
SD.A_ExitValue = new SelectInst(C1, AEV,
ExitCondition->getOperand(ExitValueNum),
- "lsplit.ev", PHTerminator);
-
+ "lsplit.ev", InsertPt);
+
Value *C2 = new ICmpInst(Sign ?
ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
BSV, StartValue, "lsplit.sv",
diff --git a/test/Transforms/LoopIndexSplit/2007-09-21-LoopBound.ll b/test/Transforms/LoopIndexSplit/2007-09-21-LoopBound.ll
new file mode 100644
index 0000000000..fa1ab2dd6b
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/2007-09-21-LoopBound.ll
@@ -0,0 +1,63 @@
+; PR1692
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output
+ %struct.CLAUSE_HELP = type { i32, i32, i32, i32, i32*, i32, %struct.LIST_NODE*, %struct.LIST_NODE*, i32, i32, %struct.LITERAL_HELP**, i32, i32, i32, i32 }
+ %struct.LIST_NODE = type { %struct.LIST_NODE*, i8* }
+ %struct.LITERAL_HELP = type { i32, i32, i32, %struct.CLAUSE_HELP*, %struct.term* }
+ %struct.anon = type { %struct.LIST_NODE* }
+ %struct.st = type { %struct.subst*, %struct.LIST_NODE*, %struct.LIST_NODE*, i16, i16 }
+ %struct.subst = type { %struct.subst*, i32, %struct.term* }
+ %struct.term = type { i32, %struct.anon, %struct.LIST_NODE*, i32, i32 }
+
+define %struct.LIST_NODE* @inf_HyperResolvents(%struct.CLAUSE_HELP* %Clause, %struct.subst* %Subst, %struct.LIST_NODE* %Restlits, i32 %GlobalMaxVar, %struct.LIST_NODE* %FoundMap, i32 %StrictlyMaximal, { %struct.st*, [3001 x %struct.term*], [4000 x %struct.term*], i32 }* %Index, i32* %Flags, i32* %Precedence) {
+entry:
+ br i1 false, label %cond_next44, label %bb37
+
+bb37: ; preds = %entry
+ ret %struct.LIST_NODE* null
+
+cond_next44: ; preds = %entry
+ br i1 false, label %bb29.i, label %bb.i31
+
+bb.i31: ; preds = %cond_next44
+ ret %struct.LIST_NODE* null
+
+bb29.i: ; preds = %cond_next44
+ br i1 false, label %cond_next89.i, label %bb34.i
+
+bb34.i: ; preds = %bb29.i
+ ret %struct.LIST_NODE* null
+
+cond_next89.i: ; preds = %bb29.i
+ br i1 false, label %clause_LiteralGetIndex.exit70.i, label %bb.i59.i
+
+bb.i59.i: ; preds = %cond_next89.i
+ ret %struct.LIST_NODE* null
+
+clause_LiteralGetIndex.exit70.i: ; preds = %cond_next89.i
+ br label %bb3.i.i
+
+bb3.i.i: ; preds = %bb3.i.i, %clause_LiteralGetIndex.exit70.i
+ br i1 false, label %bb40.i.i, label %bb3.i.i
+
+subst_Apply.exit.i.i: ; preds = %bb40.i.i
+ %tmp21.i.i = icmp sgt i32 %j.0.i.i, 0 ; <i1> [#uses=1]
+ br i1 %tmp21.i.i, label %cond_false.i47.i, label %cond_true24.i.i
+
+cond_true24.i.i: ; preds = %subst_Apply.exit.i.i
+ br label %cond_next37.i.i
+
+cond_false.i47.i: ; preds = %subst_Apply.exit.i.i
+ br label %cond_next37.i.i
+
+cond_next37.i.i: ; preds = %cond_false.i47.i, %cond_true24.i.i
+ %tmp39.i.i = add i32 %j.0.i.i, 1 ; <i32> [#uses=1]
+ br label %bb40.i.i
+
+bb40.i.i: ; preds = %cond_next37.i.i, %bb3.i.i
+ %j.0.i.i = phi i32 [ %tmp39.i.i, %cond_next37.i.i ], [ 0, %bb3.i.i ] ; <i32> [#uses=3]
+ %tmp43.i.i = icmp sgt i32 %j.0.i.i, 0 ; <i1> [#uses=1]
+ br i1 %tmp43.i.i, label %inf_CopyHyperElectron.exit.i, label %subst_Apply.exit.i.i
+
+inf_CopyHyperElectron.exit.i: ; preds = %bb40.i.i
+ ret %struct.LIST_NODE* null
+}