aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/JumpThreading
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2010-09-17 15:48:55 +0000
committerDimitry Andric <dim@FreeBSD.org>2010-09-17 15:48:55 +0000
commitd39c594d39df7f283c2fb8a704a3f31c501180d9 (patch)
tree36453626c792cccd91f783a38a169d610a6b9db9 /test/Transforms/JumpThreading
parent6144c1de6a7674dad94290650e4e14f24d42e421 (diff)
Notes
Diffstat (limited to 'test/Transforms/JumpThreading')
-rw-r--r--test/Transforms/JumpThreading/2010-08-26-and.ll162
-rw-r--r--test/Transforms/JumpThreading/basic.ll68
-rw-r--r--test/Transforms/JumpThreading/crash.ll50
-rw-r--r--test/Transforms/JumpThreading/lvi-load.ll49
4 files changed, 325 insertions, 4 deletions
diff --git a/test/Transforms/JumpThreading/2010-08-26-and.ll b/test/Transforms/JumpThreading/2010-08-26-and.ll
new file mode 100644
index 000000000000..17a0aba2faef
--- /dev/null
+++ b/test/Transforms/JumpThreading/2010-08-26-and.ll
@@ -0,0 +1,162 @@
+; RUN: opt -jump-threading -enable-jump-threading-lvi -S < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-apple-darwin10.0.0"
+
+%class.StringSwitch = type { i8*, i32, i32, i8 }
+
+@.str = private constant [4 x i8] c"red\00" ; <[4 x i8]*> [#uses=1]
+@.str1 = private constant [7 x i8] c"orange\00" ; <[7 x i8]*> [#uses=1]
+@.str2 = private constant [7 x i8] c"yellow\00" ; <[7 x i8]*> [#uses=1]
+@.str3 = private constant [6 x i8] c"green\00" ; <[6 x i8]*> [#uses=1]
+@.str4 = private constant [5 x i8] c"blue\00" ; <[5 x i8]*> [#uses=1]
+@.str5 = private constant [7 x i8] c"indigo\00" ; <[7 x i8]*> [#uses=1]
+@.str6 = private constant [7 x i8] c"violet\00" ; <[7 x i8]*> [#uses=1]
+@.str7 = private constant [12 x i8] c"Color = %d\0A\00" ; <[12 x i8]*> [#uses=1]
+
+define i32 @main(i32 %argc, i8** nocapture %argv) nounwind ssp {
+entry:
+ %cmp142 = icmp sgt i32 %argc, 1 ; <i1> [#uses=1]
+ br i1 %cmp142, label %bb.nph, label %for.end
+
+bb.nph: ; preds = %entry
+ %tmp = add i32 %argc, -2 ; <i32> [#uses=1]
+ %tmp144 = zext i32 %tmp to i64 ; <i64> [#uses=1]
+ %tmp145 = add i64 %tmp144, 1 ; <i64> [#uses=1]
+ br label %land.lhs.true.i
+
+land.lhs.true.i: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134, %bb.nph
+ %retval.0.i.pre161 = phi i32 [ undef, %bb.nph ], [ %retval.0.i.pre, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134 ] ; <i32> [#uses=3]
+ %indvar = phi i64 [ 0, %bb.nph ], [ %tmp146, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134 ] ; <i64> [#uses=1]
+ %tmp146 = add i64 %indvar, 1 ; <i64> [#uses=3]
+ %arrayidx = getelementptr i8** %argv, i64 %tmp146 ; <i8**> [#uses=1]
+ %tmp6 = load i8** %arrayidx, align 8 ; <i8*> [#uses=8]
+ %call.i.i = call i64 @strlen(i8* %tmp6) nounwind ; <i64> [#uses=1]
+ %conv.i.i = trunc i64 %call.i.i to i32 ; <i32> [#uses=6]\
+; CHECK: switch i32 %conv.i.i
+; CHECK-NOT: if.then.i40
+; CHECK: }
+ switch i32 %conv.i.i, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit [
+ i32 3, label %land.lhs.true5.i
+ i32 6, label %land.lhs.true5.i37
+ ]
+
+land.lhs.true5.i: ; preds = %land.lhs.true.i
+ %call.i = call i32 @memcmp(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i8* %tmp6, i64 4) nounwind ; <i32> [#uses=1]
+ %cmp9.i = icmp eq i32 %call.i, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i, label %_ZN12StringSwitchI5ColorE4CaseILj4EEERS1_RAT__KcRKS0_.exit, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit
+
+_ZN12StringSwitchI5ColorE4CaseILj4EEERS1_RAT__KcRKS0_.exit: ; preds = %land.lhs.true5.i
+ br label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit
+
+land.lhs.true5.i37: ; preds = %land.lhs.true.i
+ %call.i35 = call i32 @memcmp(i8* getelementptr inbounds ([7 x i8]* @.str1, i64 0, i64 0), i8* %tmp6, i64 7) nounwind ; <i32> [#uses=1]
+ %cmp9.i36 = icmp eq i32 %call.i35, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i36, label %if.then.i40, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit
+
+if.then.i40: ; preds = %land.lhs.true5.i37
+ br label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit
+
+_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit: ; preds = %if.then.i40, %land.lhs.true5.i37, %_ZN12StringSwitchI5ColorE4CaseILj4EEERS1_RAT__KcRKS0_.exit, %land.lhs.true5.i, %land.lhs.true.i
+ %retval.0.i.pre159 = phi i32 [ 1, %_ZN12StringSwitchI5ColorE4CaseILj4EEERS1_RAT__KcRKS0_.exit ], [ %retval.0.i.pre161, %land.lhs.true5.i37 ], [ 2, %if.then.i40 ], [ %retval.0.i.pre161, %land.lhs.true5.i ], [ %retval.0.i.pre161, %land.lhs.true.i ] ; <i32> [#uses=2]
+ %tmp2.i44 = phi i8 [ 1, %_ZN12StringSwitchI5ColorE4CaseILj4EEERS1_RAT__KcRKS0_.exit ], [ 0, %land.lhs.true5.i37 ], [ 1, %if.then.i40 ], [ 0, %land.lhs.true5.i ], [ 0, %land.lhs.true.i ] ; <i8> [#uses=3]
+ %tobool.i46 = icmp eq i8 %tmp2.i44, 0 ; <i1> [#uses=1]
+ %cmp.i49 = icmp eq i32 %conv.i.i, 6 ; <i1> [#uses=1]
+ %or.cond = and i1 %tobool.i46, %cmp.i49 ; <i1> [#uses=1]
+ br i1 %or.cond, label %land.lhs.true5.i55, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60
+
+land.lhs.true5.i55: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit
+ %call.i53 = call i32 @memcmp(i8* getelementptr inbounds ([7 x i8]* @.str2, i64 0, i64 0), i8* %tmp6, i64 7) nounwind ; <i32> [#uses=1]
+ %cmp9.i54 = icmp eq i32 %call.i53, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i54, label %if.then.i58, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60
+
+if.then.i58: ; preds = %land.lhs.true5.i55
+ br label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60
+
+_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60: ; preds = %if.then.i58, %land.lhs.true5.i55, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit
+ %retval.0.i.pre158 = phi i32 [ %retval.0.i.pre159, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit ], [ %retval.0.i.pre159, %land.lhs.true5.i55 ], [ 3, %if.then.i58 ] ; <i32> [#uses=2]
+ %tmp2.i63 = phi i8 [ %tmp2.i44, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit ], [ %tmp2.i44, %land.lhs.true5.i55 ], [ 1, %if.then.i58 ] ; <i8> [#uses=3]
+ %tmp14.i64 = and i8 %tmp2.i63, 1 ; <i8> [#uses=1]
+ %tobool.i65 = icmp eq i8 %tmp14.i64, 0 ; <i1> [#uses=1]
+ %cmp.i68 = icmp eq i32 %conv.i.i, 5 ; <i1> [#uses=1]
+ %or.cond168 = and i1 %tobool.i65, %cmp.i68 ; <i1> [#uses=1]
+ br i1 %or.cond168, label %land.lhs.true5.i74, label %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit
+
+land.lhs.true5.i74: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60
+ %call.i72 = call i32 @memcmp(i8* getelementptr inbounds ([6 x i8]* @.str3, i64 0, i64 0), i8* %tmp6, i64 6) nounwind ; <i32> [#uses=1]
+ %cmp9.i73 = icmp eq i32 %call.i72, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i73, label %if.then.i77, label %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit
+
+if.then.i77: ; preds = %land.lhs.true5.i74
+ br label %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit
+
+_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit: ; preds = %if.then.i77, %land.lhs.true5.i74, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60
+ %retval.0.i.pre157 = phi i32 [ %retval.0.i.pre158, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60 ], [ %retval.0.i.pre158, %land.lhs.true5.i74 ], [ 4, %if.then.i77 ] ; <i32> [#uses=2]
+ %tmp2.i81 = phi i8 [ %tmp2.i63, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit60 ], [ %tmp2.i63, %land.lhs.true5.i74 ], [ 1, %if.then.i77 ] ; <i8> [#uses=3]
+ %tmp14.i82 = and i8 %tmp2.i81, 1 ; <i8> [#uses=1]
+ %tobool.i83 = icmp eq i8 %tmp14.i82, 0 ; <i1> [#uses=1]
+ %cmp.i86 = icmp eq i32 %conv.i.i, 4 ; <i1> [#uses=1]
+ %or.cond169 = and i1 %tobool.i83, %cmp.i86 ; <i1> [#uses=1]
+ br i1 %or.cond169, label %land.lhs.true5.i92, label %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit
+
+land.lhs.true5.i92: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit
+ %call.i90 = call i32 @memcmp(i8* getelementptr inbounds ([5 x i8]* @.str4, i64 0, i64 0), i8* %tmp6, i64 5) nounwind ; <i32> [#uses=1]
+ %cmp9.i91 = icmp eq i32 %call.i90, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i91, label %if.then.i95, label %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit
+
+if.then.i95: ; preds = %land.lhs.true5.i92
+ br label %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit
+
+_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit: ; preds = %if.then.i95, %land.lhs.true5.i92, %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit
+ %retval.0.i.pre156 = phi i32 [ %retval.0.i.pre157, %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit ], [ %retval.0.i.pre157, %land.lhs.true5.i92 ], [ 5, %if.then.i95 ] ; <i32> [#uses=2]
+ %tmp2.i99 = phi i8 [ %tmp2.i81, %_ZN12StringSwitchI5ColorE4CaseILj6EEERS1_RAT__KcRKS0_.exit ], [ %tmp2.i81, %land.lhs.true5.i92 ], [ 1, %if.then.i95 ] ; <i8> [#uses=3]
+ %tmp14.i100 = and i8 %tmp2.i99, 1 ; <i8> [#uses=1]
+ %tobool.i101 = icmp eq i8 %tmp14.i100, 0 ; <i1> [#uses=1]
+ %cmp.i104 = icmp eq i32 %conv.i.i, 6 ; <i1> [#uses=1]
+ %or.cond170 = and i1 %tobool.i101, %cmp.i104 ; <i1> [#uses=1]
+ br i1 %or.cond170, label %land.lhs.true5.i110, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115
+
+land.lhs.true5.i110: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit
+ %call.i108 = call i32 @memcmp(i8* getelementptr inbounds ([7 x i8]* @.str5, i64 0, i64 0), i8* %tmp6, i64 7) nounwind ; <i32> [#uses=1]
+ %cmp9.i109 = icmp eq i32 %call.i108, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i109, label %if.then.i113, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115
+
+if.then.i113: ; preds = %land.lhs.true5.i110
+ br label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115
+
+_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115: ; preds = %if.then.i113, %land.lhs.true5.i110, %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit
+ %retval.0.i.pre155 = phi i32 [ %retval.0.i.pre156, %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit ], [ %retval.0.i.pre156, %land.lhs.true5.i110 ], [ 6, %if.then.i113 ] ; <i32> [#uses=2]
+ %tmp2.i118 = phi i8 [ %tmp2.i99, %_ZN12StringSwitchI5ColorE4CaseILj5EEERS1_RAT__KcRKS0_.exit ], [ %tmp2.i99, %land.lhs.true5.i110 ], [ 1, %if.then.i113 ] ; <i8> [#uses=3]
+ %tmp14.i119 = and i8 %tmp2.i118, 1 ; <i8> [#uses=1]
+ %tobool.i120 = icmp eq i8 %tmp14.i119, 0 ; <i1> [#uses=1]
+ %cmp.i123 = icmp eq i32 %conv.i.i, 6 ; <i1> [#uses=1]
+ %or.cond171 = and i1 %tobool.i120, %cmp.i123 ; <i1> [#uses=1]
+ br i1 %or.cond171, label %land.lhs.true5.i129, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134
+
+land.lhs.true5.i129: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115
+ %call.i127 = call i32 @memcmp(i8* getelementptr inbounds ([7 x i8]* @.str6, i64 0, i64 0), i8* %tmp6, i64 7) nounwind ; <i32> [#uses=1]
+ %cmp9.i128 = icmp eq i32 %call.i127, 0 ; <i1> [#uses=1]
+ br i1 %cmp9.i128, label %if.then.i132, label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134
+
+if.then.i132: ; preds = %land.lhs.true5.i129
+ br label %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134
+
+_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134: ; preds = %if.then.i132, %land.lhs.true5.i129, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115
+ %retval.0.i.pre = phi i32 [ %retval.0.i.pre155, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115 ], [ %retval.0.i.pre155, %land.lhs.true5.i129 ], [ 7, %if.then.i132 ] ; <i32> [#uses=2]
+ %tmp2.i137 = phi i8 [ %tmp2.i118, %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit115 ], [ %tmp2.i118, %land.lhs.true5.i129 ], [ 1, %if.then.i132 ] ; <i8> [#uses=1]
+ %tmp7.i138 = and i8 %tmp2.i137, 1 ; <i8> [#uses=1]
+ %tobool.i139 = icmp eq i8 %tmp7.i138, 0 ; <i1> [#uses=1]
+ %retval.0.i = select i1 %tobool.i139, i32 0, i32 %retval.0.i.pre ; <i32> [#uses=1]
+ %call22 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str7, i64 0, i64 0), i32 %retval.0.i) ; <i32> [#uses=0]
+ %exitcond = icmp eq i64 %tmp146, %tmp145 ; <i1> [#uses=1]
+ br i1 %exitcond, label %for.end, label %land.lhs.true.i
+
+for.end: ; preds = %_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit134, %entry
+ ret i32 0
+}
+
+declare i32 @printf(i8* nocapture, ...) nounwind
+
+declare i32 @memcmp(i8* nocapture, i8* nocapture, i64) nounwind readonly
+
+declare i64 @strlen(i8* nocapture) nounwind readonly
diff --git a/test/Transforms/JumpThreading/basic.ll b/test/Transforms/JumpThreading/basic.ll
index 503d301892ee..cd274e78c9fc 100644
--- a/test/Transforms/JumpThreading/basic.ll
+++ b/test/Transforms/JumpThreading/basic.ll
@@ -147,11 +147,17 @@ define i32 @test6(i32 %A) {
; CHECK: @test6
%tmp455 = icmp eq i32 %A, 42
br i1 %tmp455, label %BB1, label %BB2
-
-BB2:
+
+; CHECK: call i32 @f2()
+; CHECK-NEXT: ret i32 3
+
; CHECK: call i32 @f1()
-; CHECK-NEXT: call void @f3()
-; CHECK-NEXT: ret i32 4
+; CHECK-NOT: br
+; CHECK: call void @f3()
+; CHECK-NOT: br
+; CHECK: ret i32 4
+
+BB2:
call i32 @f1()
br label %BB1
@@ -415,4 +421,58 @@ F2:
; CHECK-NEXT: br i1 %N, label %T2, label %F2
}
+; CHECK: @test14
+define i32 @test14(i32 %in) {
+entry:
+ %A = icmp eq i32 %in, 0
+; CHECK: br i1 %A, label %right_ret, label %merge
+ br i1 %A, label %left, label %right
+
+; CHECK-NOT: left:
+left:
+ br label %merge
+
+; CHECK-NOT: right:
+right:
+ %B = call i32 @f1()
+ br label %merge
+
+merge:
+; CHECK-NOT: %C = phi i32 [%in, %left], [%B, %right]
+ %C = phi i32 [%in, %left], [%B, %right]
+ %D = add i32 %C, 1
+ %E = icmp eq i32 %D, 2
+ br i1 %E, label %left_ret, label %right_ret
+
+; CHECK: left_ret:
+left_ret:
+ ret i32 0
+
+right_ret:
+ ret i32 1
+}
+
+; PR5652
+; CHECK: @test15
+define i32 @test15(i32 %len) {
+entry:
+; CHECK: icmp ult i32 %len, 13
+ %tmp = icmp ult i32 %len, 13
+ br i1 %tmp, label %check, label %exit0
+
+exit0:
+ ret i32 0
+
+check:
+ %tmp9 = icmp ult i32 %len, 21
+ br i1 %tmp9, label %exit1, label %exit2
+
+exit2:
+; CHECK-NOT: ret i32 2
+ ret i32 2
+
+exit1:
+ ret i32 1
+; CHECK: }
+}
diff --git a/test/Transforms/JumpThreading/crash.ll b/test/Transforms/JumpThreading/crash.ll
index f0fc61e7370f..751bc6518a1a 100644
--- a/test/Transforms/JumpThreading/crash.ll
+++ b/test/Transforms/JumpThreading/crash.ll
@@ -216,6 +216,9 @@ bb61:
; PR5698
define void @test7(i32 %x) {
+entry:
+ br label %tailrecurse
+
tailrecurse:
switch i32 %x, label %return [
i32 2, label %bb2
@@ -433,4 +436,51 @@ for.cond1040: ; preds = %for.body1044, %for.
ret void
}
+; PR7755
+define void @test16(i1 %c, i1 %c2, i1 %c3, i1 %c4) nounwind ssp {
+entry:
+ %cmp = icmp sgt i32 undef, 1 ; <i1> [#uses=1]
+ br i1 %c, label %land.end, label %land.rhs
+
+land.rhs: ; preds = %entry
+ br i1 %c2, label %lor.lhs.false.i, label %land.end
+
+lor.lhs.false.i: ; preds = %land.rhs
+ br i1 %c3, label %land.end, label %land.end
+
+land.end:
+ %0 = phi i1 [ true, %entry ], [ false, %land.rhs ], [false, %lor.lhs.false.i], [false, %lor.lhs.false.i] ; <i1> [#uses=1]
+ %cmp12 = and i1 %cmp, %0
+ %xor1 = xor i1 %cmp12, %c4
+ br i1 %xor1, label %if.then, label %if.end
+
+if.then:
+ ret void
+
+if.end:
+ ret void
+}
+
+define void @test17() {
+entry:
+ br i1 undef, label %bb269.us.us, label %bb269.us.us.us
+
+bb269.us.us.us:
+ %indvar = phi i64 [ %indvar.next, %bb287.us.us.us ], [ 0, %entry ]
+ %0 = icmp eq i16 undef, 0
+ br i1 %0, label %bb287.us.us.us, label %bb286.us.us.us
+
+bb287.us.us.us:
+ %indvar.next = add i64 %indvar, 1
+ %exitcond = icmp eq i64 %indvar.next, 4
+ br i1 %exitcond, label %bb288.bb289.loopexit_crit_edge, label %bb269.us.us.us
+bb286.us.us.us:
+ unreachable
+
+bb269.us.us:
+ unreachable
+
+bb288.bb289.loopexit_crit_edge:
+ unreachable
+}
diff --git a/test/Transforms/JumpThreading/lvi-load.ll b/test/Transforms/JumpThreading/lvi-load.ll
new file mode 100644
index 000000000000..0bf4187d544b
--- /dev/null
+++ b/test/Transforms/JumpThreading/lvi-load.ll
@@ -0,0 +1,49 @@
+; RUN: opt -S -jump-threading -enable-jump-threading-lvi -dce < %s | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-apple-darwin10.4"
+
+%"struct.llvm::PATypeHolder" = type { %"struct.llvm::Type"* }
+%"struct.llvm::PointerIntPair<llvm::Use**,2u,llvm::Use::PrevPtrTag,llvm::PointerLikeTypeTraits<llvm::Use**> >" = type { i64 }
+%"struct.llvm::Type" = type opaque
+%"struct.llvm::Use" = type { %"struct.llvm::Value"*, %"struct.llvm::Use"*, %"struct.llvm::PointerIntPair<llvm::Use**,2u,llvm::Use::PrevPtrTag,llvm::PointerLikeTypeTraits<llvm::Use**> >" }
+%"struct.llvm::Value" = type { i32 (...)**, i8, i8, i16, %"struct.llvm::PATypeHolder", %"struct.llvm::Use"*, %"struct.llvm::ValueName"* }
+%"struct.llvm::ValueName" = type opaque
+
+@_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__ = internal constant [5 x i8] c"cast\00", align 8 ; <[5 x i8]*> [#uses=1]
+@.str = private constant [31 x i8] c"include/llvm/Support/Casting.h\00", align 8 ; <[31 x i8]*> [#uses=1]
+@.str1 = private constant [59 x i8] c"isa<X>(Val) && \22cast<Ty>() argument of incompatible type!\22\00", align 8 ; <[59 x i8]*> [#uses=1]
+
+; CHECK: Z3fooPN4llvm5ValueE
+define zeroext i8 @_Z3fooPN4llvm5ValueE(%"struct.llvm::Value"* %V) ssp {
+entry:
+ %0 = getelementptr inbounds %"struct.llvm::Value"* %V, i64 0, i32 1 ; <i8*> [#uses=1]
+ %1 = load i8* %0, align 8 ; <i8> [#uses=2]
+ %2 = icmp ugt i8 %1, 20 ; <i1> [#uses=1]
+ br i1 %2, label %bb.i, label %bb2
+
+bb.i: ; preds = %entry
+ %toBoolnot.i.i = icmp ult i8 %1, 21 ; <i1> [#uses=1]
+ br i1 %toBoolnot.i.i, label %bb6.i.i, label %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
+
+; CHECK-NOT: assert
+bb6.i.i: ; preds = %bb.i
+ tail call void @__assert_rtn(i8* getelementptr inbounds ([5 x i8]* @_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8]* @.str, i64 0, i64 0), i32 202, i8* getelementptr inbounds ([59 x i8]* @.str1, i64 0, i64 0)) noreturn
+ unreachable
+
+_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit: ; preds = %bb.i
+; CHECK-NOT: null
+ %3 = icmp eq %"struct.llvm::Value"* %V, null ; <i1> [#uses=1]
+ br i1 %3, label %bb2, label %bb
+
+bb: ; preds = %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
+ tail call void @_ZNK4llvm5Value4dumpEv(%"struct.llvm::Value"* %V)
+; CHECK: ret
+ ret i8 1
+
+bb2: ; preds = %entry, %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
+ ret i8 0
+}
+
+declare void @__assert_rtn(i8*, i8*, i32, i8*) noreturn
+
+declare void @_ZNK4llvm5Value4dumpEv(%"struct.llvm::Value"*)