diff options
Diffstat (limited to 'llvm/test/Transforms/JumpThreading')
56 files changed, 0 insertions, 6405 deletions
diff --git a/llvm/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll b/llvm/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll deleted file mode 100644 index 6a50d4f1a32..00000000000 --- a/llvm/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll +++ /dev/null @@ -1,13 +0,0 @@ -; RUN: opt < %s -jump-threading -S | grep "ret i32 0" -; PR3138 - -define i32 @jt() { -entry: - br i1 true, label %bb3, label %bb - -bb: ; preds = %entry - unreachable - -bb3: ; preds = %entry - ret i32 0 -} diff --git a/llvm/test/Transforms/JumpThreading/2010-08-26-and.ll b/llvm/test/Transforms/JumpThreading/2010-08-26-and.ll deleted file mode 100644 index cc56ac9cc84..00000000000 --- a/llvm/test/Transforms/JumpThreading/2010-08-26-and.ll +++ /dev/null @@ -1,162 +0,0 @@ -; RUN: opt -jump-threading -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*, i8** %argv, i64 %tmp146 ; <i8**> [#uses=1] - %tmp6 = load i8*, 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], [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], [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], [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], [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], [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], [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], [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], [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/llvm/test/Transforms/JumpThreading/2011-04-02-SimplifyDeadBlock.ll b/llvm/test/Transforms/JumpThreading/2011-04-02-SimplifyDeadBlock.ll deleted file mode 100644 index 76dd2d12bde..00000000000 --- a/llvm/test/Transforms/JumpThreading/2011-04-02-SimplifyDeadBlock.ll +++ /dev/null @@ -1,32 +0,0 @@ -; RUN: opt < %s -jump-threading -; PR9446 -; Just check that it doesn't crash - -define void @int327() nounwind { -entry: - unreachable - -for.cond: ; preds = %for.cond4 - %tobool3 = icmp eq i8 undef, 0 - br i1 %tobool3, label %for.cond23, label %for.cond4 - -for.cond4: ; preds = %for.cond - br label %for.cond - -for.cond23: ; preds = %for.body28, %for.cond23, %for.cond - %conv321 = phi i32 [ %conv32, %for.body28 ], [ 0, %for.cond ], [ %conv321, %for.cond23 ] - %l_266.0 = phi i32 [ %phitmp, %for.body28 ], [ 0, %for.cond ], [ 0, %for.cond23 ] - %cmp26 = icmp eq i32 %l_266.0, 0 - br i1 %cmp26, label %for.body28, label %for.cond23 - -for.body28: ; preds = %for.cond23 - %and = and i32 %conv321, 1 - %conv32 = zext i8 undef to i32 - %add = add nsw i32 %l_266.0, 1 - %phitmp = and i32 %add, 255 - br label %for.cond23 - -if.end43: ; No predecessors! - ret void -} - diff --git a/llvm/test/Transforms/JumpThreading/2011-04-14-InfLoop.ll b/llvm/test/Transforms/JumpThreading/2011-04-14-InfLoop.ll deleted file mode 100644 index 0323723a3a8..00000000000 --- a/llvm/test/Transforms/JumpThreading/2011-04-14-InfLoop.ll +++ /dev/null @@ -1,27 +0,0 @@ -; RUN: opt -jump-threading < %s -; <rdar://problem/9284786> - -%0 = type <{ i64, i16, i64, i8, i8 }> - -@g_338 = external global %0, align 8 - -define void @func_1() nounwind ssp { -entry: - ret void - -for.cond1177: - %inc1187 = add nsw i32 0, 1 - %cmp1179 = icmp slt i32 %inc1187, 5 - br i1 %cmp1179, label %for.cond1177, label %land.rhs1320 - -land.rhs1320: - %tmp1324 = load volatile i64, i64* getelementptr inbounds (%0, %0* @g_338, i64 0, i32 2), align 1 - br label %if.end.i - -if.end.i: - %tobool.pr.i = phi i1 [ false, %if.end.i ], [ false, %land.rhs1320 ] - br i1 %tobool.pr.i, label %return, label %if.end.i - -return: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll b/llvm/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll deleted file mode 100644 index 1c2c0c75e36..00000000000 --- a/llvm/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll +++ /dev/null @@ -1,8 +0,0 @@ -; RUN: opt < %s -jump-threading -; PR 13405 -; Just check that it doesn't crash / assert - -define i32 @f() nounwind { -entry: - indirectbr i8* undef, [] -} diff --git a/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll b/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll deleted file mode 100644 index e328f32c9c3..00000000000 --- a/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll +++ /dev/null @@ -1,37 +0,0 @@ -; RUN: opt -S -jump-threading -verify -o - %s | FileCheck %s -@a = external global i16, align 1 - -; CHECK-LABEL: f -; CHECK: bb6: -; CHECK: bb2: -; CHECK: bb3: -; CHECK-NOT: bb0: -; CHECK-NOT: bb1: -; CHECK-NOT: bb4: -; CHECK-NOT: bb5: -define void @f(i32 %p1) { -bb0: - %0 = icmp eq i32 %p1, 0 - br i1 undef, label %bb6, label %bb1 - -bb1: - br label %bb2 - -bb2: - %1 = phi i1 [ %0, %bb1 ], [ %2, %bb4 ] - %2 = and i1 %1, undef - br i1 %2, label %bb3, label %bb4 - -bb3: - store i16 undef, i16* @a, align 1 - br label %bb4 - -bb4: - br i1 %0, label %bb2, label %bb5 - -bb5: - unreachable - -bb6: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/PR37745.ll b/llvm/test/Transforms/JumpThreading/PR37745.ll deleted file mode 100644 index 82fc9191182..00000000000 --- a/llvm/test/Transforms/JumpThreading/PR37745.ll +++ /dev/null @@ -1,19 +0,0 @@ -; RUN: opt -jump-threading -verify-each -S -mtriple=x86_64-- -o - %s - -define void @foo() { -entry: - br i1 false, label %A, label %B - -A: - %x = phi i32 [ undef, %entry ], [ %z, %B ] - br label %B - -B: - %y = phi i32 [ undef, %entry ], [ %x, %A ] - %z = add i32 %y, 1 - %cmp = icmp ne i32 %z, 0 - br i1 %cmp, label %exit, label %A - -exit: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/and-and-cond.ll b/llvm/test/Transforms/JumpThreading/and-and-cond.ll deleted file mode 100644 index 765d940cc7c..00000000000 --- a/llvm/test/Transforms/JumpThreading/and-and-cond.ll +++ /dev/null @@ -1,37 +0,0 @@ -; RUN: opt < %s -jump-threading -mem2reg -instcombine -simplifycfg -S | FileCheck %s - -declare i32 @f1() -declare i32 @f2() -declare void @f3() - -define i32 @test(i1 %cond, i1 %cond2, i1 %cond3) { -; CHECK: test - br i1 %cond, label %T1, label %F1 - -; CHECK-NOT: T1: -T1: - %v1 = call i32 @f1() - br label %Merge - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: -; CHECK: Merge: -; CHECK: %v1 = call i32 @f1() -; CHECK-NEXT: %D = and i1 %cond2, %cond3 -; CHECK-NEXT: br i1 %D - %A = phi i1 [true, %T1], [false, %F1] - %B = phi i32 [%v1, %T1], [%v2, %F1] - %C = and i1 %A, %cond2 - %D = and i1 %C, %cond3 - br i1 %D, label %T2, label %F2 - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -} diff --git a/llvm/test/Transforms/JumpThreading/and-cond.ll b/llvm/test/Transforms/JumpThreading/and-cond.ll deleted file mode 100644 index 0159bb3bb76..00000000000 --- a/llvm/test/Transforms/JumpThreading/and-cond.ll +++ /dev/null @@ -1,35 +0,0 @@ -; RUN: opt < %s -jump-threading -mem2reg -instcombine -simplifycfg -S | FileCheck %s - -declare i32 @f1() -declare i32 @f2() -declare void @f3() - -define i32 @test(i1 %cond, i1 %cond2) { -; CHECK: test - br i1 %cond, label %T1, label %F1 - -; CHECK-NOT: T1 -T1: - %v1 = call i32 @f1() - br label %Merge - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: -; CHECK: Merge: -; CHECK: %v1 = call i32 @f1() -; CHECK-NEXT: br i1 %cond2 - %A = phi i1 [true, %T1], [false, %F1] - %B = phi i32 [%v1, %T1], [%v2, %F1] - %C = and i1 %A, %cond2 - br i1 %C, label %T2, label %F2 - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -} diff --git a/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll b/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll deleted file mode 100644 index f1d0f41e250..00000000000 --- a/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll +++ /dev/null @@ -1,39 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - -declare i8* @escape() -declare void @llvm.assume(i1) - -define i1 @test1(i1 %cond) { -entry: - br i1 %cond, label %taken, label %not_taken - -; CHECK-LABEL: @test1 -; CHECK: br i1 %cond, label %no, label %yes -; CHECK: ret i1 true - -taken: - %res1 = call i8* @escape() - %a = icmp eq i8* %res1, null - tail call void @llvm.assume(i1 %a) - br label %done -not_taken: - %res2 = call i8* @escape() - %b = icmp ne i8* %res2, null - tail call void @llvm.assume(i1 %b) - br label %done - -; An assume that can be used to simplify this comparison dominates each -; predecessor branch (although no assume dominates the cmp itself). Make sure -; this still can be simplified. - -done: - %res = phi i8* [ %res1, %taken ], [ %res2, %not_taken ] - %cnd = icmp ne i8* %res, null - br i1 %cnd, label %yes, label %no - -yes: - ret i1 true -no: - ret i1 false -} - diff --git a/llvm/test/Transforms/JumpThreading/assume.ll b/llvm/test/Transforms/JumpThreading/assume.ll deleted file mode 100644 index f58ee299cba..00000000000 --- a/llvm/test/Transforms/JumpThreading/assume.ll +++ /dev/null @@ -1,241 +0,0 @@ -; RUN: opt -S -jump-threading -dce < %s | FileCheck %s -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -; Function Attrs: nounwind uwtable -define i32 @test1(i32 %a, i32 %b) #0 { -entry: - %cmp = icmp sgt i32 %a, 5 - tail call void @llvm.assume(i1 %cmp) - %cmp1 = icmp sgt i32 %b, 1234 - br i1 %cmp1, label %if.then, label %if.else - -; CHECK-LABEL: @test1 -; CHECK: icmp sgt i32 %a, 5 -; CHECK: call void @llvm.assume -; CHECK-NOT: icmp sgt i32 %a, 3 -; CHECK: ret i32 - -if.then: ; preds = %entry - %cmp2 = icmp sgt i32 %a, 3 - br i1 %cmp2, label %if.then3, label %return - -if.then3: ; preds = %if.then - tail call void (...) @bar() #1 - br label %return - -if.else: ; preds = %entry - tail call void (...) @car() #1 - br label %return - -return: ; preds = %if.else, %if.then, %if.then3 - %retval.0 = phi i32 [ 1, %if.then3 ], [ 0, %if.then ], [ 0, %if.else ] - ret i32 %retval.0 -} - -define i32 @test2(i32 %a) #0 { -entry: - %cmp = icmp sgt i32 %a, 5 - tail call void @llvm.assume(i1 %cmp) - %cmp1 = icmp sgt i32 %a, 3 - br i1 %cmp1, label %if.then, label %return - -; CHECK-LABEL: @test2 -; CHECK: icmp sgt i32 %a, 5 -; CHECK: tail call void @llvm.assume -; CHECK: tail call void (...) @bar() -; CHECK: ret i32 1 - - -if.then: ; preds = %entry - tail call void (...) @bar() #1 - br label %return - -return: ; preds = %entry, %if.then - %retval.0 = phi i32 [ 1, %if.then ], [ 0, %entry ] - ret i32 %retval.0 -} - -@g = external global i32 - -; Check that we do prove a fact using an assume within the block. -; We can fold the assume based on the semantics of assume. -define void @can_fold_assume(i32* %array) { -; CHECK-LABEL: @can_fold_assume -; CHECK-NOT: call void @llvm.assume -; CHECK-NOT: br -; CHECK: ret void - %notnull = icmp ne i32* %array, null - call void @llvm.assume(i1 %notnull) - br i1 %notnull, label %normal, label %error - -normal: - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void -} - -declare void @f(i1) -declare void @exit() -; We can fold the assume but not the uses before the assume. -define void @cannot_fold_use_before_assume(i32* %array) { -; CHECK-LABEL:@cannot_fold_use_before_assume -; CHECK: @f(i1 %notnull) -; CHECK-NEXT: exit() -; CHECK-NOT: assume -; CHECK-NEXT: ret void - %notnull = icmp ne i32* %array, null - call void @f(i1 %notnull) - call void @exit() - call void @llvm.assume(i1 %notnull) - br i1 %notnull, label %normal, label %error - -normal: - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void -} - -declare void @dummy(i1) nounwind argmemonly -define void @can_fold_some_use_before_assume(i32* %array) { - -; CHECK-LABEL:@can_fold_some_use_before_assume -; CHECK: @f(i1 %notnull) -; CHECK-NEXT: @dummy(i1 true) -; CHECK-NOT: assume -; CHECK-NEXT: ret void - %notnull = icmp ne i32* %array, null - call void @f(i1 %notnull) - call void @dummy(i1 %notnull) - call void @llvm.assume(i1 %notnull) - br i1 %notnull, label %normal, label %error - -normal: - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void - -} - -; FIXME: can fold assume and all uses before/after assume. -; because the trapping exit call is after the assume. -define void @can_fold_assume_and_all_uses(i32* %array) { -; CHECK-LABEL:@can_fold_assume_and_all_uses -; CHECK: @dummy(i1 %notnull) -; CHECK-NEXT: assume(i1 %notnull) -; CHECK-NEXT: exit() -; CHECK-NEXT: %notnull2 = or i1 true, false -; CHECK-NEXT: @f(i1 %notnull2) -; CHECK-NEXT: ret void - %notnull = icmp ne i32* %array, null - call void @dummy(i1 %notnull) - call void @llvm.assume(i1 %notnull) - call void @exit() - br i1 %notnull, label %normal, label %error - -normal: - %notnull2 = or i1 %notnull, false - call void @f(i1 %notnull2) - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void -} - -declare void @fz(i8) -; FIXME: We can fold assume to true, and the use after assume, but we do not do so -; currently, because of the function call after the assume. -define void @can_fold_assume2(i32* %array) { - -; CHECK-LABEL:@can_fold_assume2 -; CHECK: @f(i1 %notnull) -; CHECK-NEXT: assume(i1 %notnull) -; CHECK-NEXT: znotnull = zext i1 %notnull to i8 -; CHECK-NEXT: @f(i1 %notnull) -; CHECK-NEXT: @f(i1 true) -; CHECK-NEXT: @fz(i8 %znotnull) -; CHECK-NEXT: ret void - %notnull = icmp ne i32* %array, null - call void @f(i1 %notnull) - call void @llvm.assume(i1 %notnull) - %znotnull = zext i1 %notnull to i8 - call void @f(i1 %notnull) - br i1 %notnull, label %normal, label %error - -normal: - call void @f(i1 %notnull) - call void @fz(i8 %znotnull) - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void -} - -declare void @llvm.experimental.guard(i1, ...) -; FIXME: We can fold assume to true, but we do not do so -; because of the guard following the assume. -define void @can_fold_assume3(i32* %array){ - -; CHECK-LABEL:@can_fold_assume3 -; CHECK: @f(i1 %notnull) -; CHECK-NEXT: assume(i1 %notnull) -; CHECK-NEXT: guard(i1 %notnull) -; CHECK-NEXT: znotnull = zext i1 true to i8 -; CHECK-NEXT: @f(i1 true) -; CHECK-NEXT: @fz(i8 %znotnull) -; CHECK-NEXT: ret void - %notnull = icmp ne i32* %array, null - call void @f(i1 %notnull) - call void @llvm.assume(i1 %notnull) - call void(i1, ...) @llvm.experimental.guard(i1 %notnull) [ "deopt"() ] - %znotnull = zext i1 %notnull to i8 - br i1 %notnull, label %normal, label %error - -normal: - call void @f(i1 %notnull) - call void @fz(i8 %znotnull) - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void -} - - -; can fold all uses and remove the cond -define void @can_fold_assume4(i32* %array) { -; CHECK-LABEL: can_fold_assume4 -; CHECK-NOT: notnull -; CHECK: dummy(i1 true) -; CHECK-NEXT: ret void - %notnull = icmp ne i32* %array, null - call void @exit() - call void @dummy(i1 %notnull) - call void @llvm.assume(i1 %notnull) - br i1 %notnull, label %normal, label %error - -normal: - ret void - -error: - store atomic i32 0, i32* @g unordered, align 4 - ret void -} -; Function Attrs: nounwind -declare void @llvm.assume(i1) #1 - -declare void @bar(...) - -declare void @car(...) - -attributes #0 = { nounwind uwtable } -attributes #1 = { nounwind } - diff --git a/llvm/test/Transforms/JumpThreading/basic.ll b/llvm/test/Transforms/JumpThreading/basic.ll deleted file mode 100644 index 16e7549e3fc..00000000000 --- a/llvm/test/Transforms/JumpThreading/basic.ll +++ /dev/null @@ -1,610 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s - -declare i32 @f1() -declare i32 @f2() -declare void @f3() - -define i32 @test1(i1 %cond) { -; CHECK-LABEL: @test1( - - br i1 %cond, label %T1, label %F1 - -T1: - %v1 = call i32 @f1() - br label %Merge - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: - %A = phi i1 [true, %T1], [false, %F1] - %B = phi i32 [%v1, %T1], [%v2, %F1] - br i1 %A, label %T2, label %F2 - -T2: -; CHECK: T2: -; CHECK: ret i32 %v1 - call void @f3() - ret i32 %B - -F2: -; CHECK: F2: -; CHECK: ret i32 %v2 - ret i32 %B -} - - -;; cond is known false on Entry -> F1 edge! -define i32 @test2(i1 %cond) { -; CHECK-LABEL: @test2( -Entry: - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: %v1 = call i32 @f1() -; CHECK: ret i32 47 - %v1 = call i32 @f1() - br label %Merge - -F1: - br i1 %cond, label %Merge, label %F2 - -Merge: - %B = phi i32 [47, %T1], [192, %F1] - ret i32 %B - -F2: - call void @f3() - ret i32 12 -} - - -; Undef handling. -define i32 @test3(i1 %cond) { -; CHECK-LABEL: @test3( -; CHECK-NEXT: T1: -; CHECK-NEXT: ret i32 42 - br i1 undef, label %T1, label %F1 - -T1: - ret i32 42 - -F1: - ret i32 17 -} - -define i32 @test4(i1 %cond, i1 %cond2) { -; CHECK-LABEL: @test4( - - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: %v1 = call i32 @f1() -; CHECK-NEXT: br label %T - - %v1 = call i32 @f1() - br label %Merge - -F1: - %v2 = call i32 @f2() -; CHECK: %v2 = call i32 @f2() -; CHECK-NEXT: br i1 %cond2, - br label %Merge - -Merge: - %A = phi i1 [undef, %T1], [%cond2, %F1] - %B = phi i32 [%v1, %T1], [%v2, %F1] - br i1 %A, label %T2, label %F2 - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -} - - -;; This tests that the branch in 'merge' can be cloned up into T1. -define i32 @test5(i1 %cond, i1 %cond2) { -; CHECK-LABEL: @test5( - - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: T1: -; CHECK-NEXT: %v1 = call i32 @f1() -; CHECK-NEXT: %cond3 = icmp eq i32 %v1, 412 -; CHECK-NEXT: br i1 %cond3, label %T2, label %F2 - - %v1 = call i32 @f1() - %cond3 = icmp eq i32 %v1, 412 - br label %Merge - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: - %A = phi i1 [%cond3, %T1], [%cond2, %F1] - %B = phi i32 [%v1, %T1], [%v2, %F1] - br i1 %A, label %T2, label %F2 - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -} - - -;; Lexically duplicated conditionals should be threaded. - - -define i32 @test6(i32 %A) { -; CHECK-LABEL: @test6( - %tmp455 = icmp eq i32 %A, 42 - br i1 %tmp455, label %BB1, label %BB2 - -; CHECK: call i32 @f2() -; CHECK-NEXT: ret i32 3 - -; CHECK: call i32 @f1() -; CHECK-NOT: br -; CHECK: call void @f3() -; CHECK-NOT: br -; CHECK: ret i32 4 - -BB2: - call i32 @f1() - br label %BB1 - - -BB1: - %tmp459 = icmp eq i32 %A, 42 - br i1 %tmp459, label %BB3, label %BB4 - -BB3: - call i32 @f2() - ret i32 3 - -BB4: - call void @f3() - ret i32 4 -} - - -;; This tests that the branch in 'merge' can be cloned up into T1. -;; rdar://7367025 -define i32 @test7(i1 %cond, i1 %cond2) { -Entry: -; CHECK-LABEL: @test7( - %v1 = call i32 @f1() - br i1 %cond, label %Merge, label %F1 - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: - %B = phi i32 [%v1, %Entry], [%v2, %F1] - %M = icmp ne i32 %B, %v1 - %N = icmp eq i32 %B, 47 - %O = and i1 %M, %N - br i1 %O, label %T2, label %F2 - -; CHECK: Merge: -; CHECK-NOT: phi -; CHECK-NEXT: %v2 = call i32 @f2() - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -; CHECK: F2: -; CHECK-NEXT: phi i32 -} - - -declare i1 @test8a() - -define i32 @test8b(i1 %cond, i1 %cond2) { -; CHECK-LABEL: @test8b( -T0: - %A = call i1 @test8a() - br i1 %A, label %T1, label %F1 - -; CHECK: T0: -; CHECK-NEXT: call -; CHECK-NEXT: br i1 %A, label %T1, label %Y - -T1: - %B = call i1 @test8a() - br i1 %B, label %T2, label %F1 - -; CHECK: T1: -; CHECK-NEXT: call -; CHECK-NEXT: br i1 %B, label %T2, label %Y -T2: - %C = call i1 @test8a() - br i1 %cond, label %T3, label %F1 - -; CHECK: T2: -; CHECK-NEXT: call -; CHECK-NEXT: br i1 %cond, label %T3, label %Y -T3: - ret i32 0 - -F1: - %D = phi i32 [0, %T0], [0, %T1], [1, %T2] - %E = icmp eq i32 %D, 1 - %F = and i1 %E, %cond - br i1 %F, label %X, label %Y -X: - call i1 @test8a() - ret i32 1 -Y: - ret i32 2 -} - - -;;; Verify that we can handle constraint propagation through "xor x, 1". -define i32 @test9(i1 %cond, i1 %cond2) { -Entry: -; CHECK-LABEL: @test9( - %v1 = call i32 @f1() - br i1 %cond, label %Merge, label %F1 - -; CHECK: Entry: -; CHECK-NEXT: %v1 = call i32 @f1() -; CHECK-NEXT: br i1 %cond, label %F2, label %Merge - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: - %B = phi i32 [%v1, %Entry], [%v2, %F1] - %M = icmp eq i32 %B, %v1 - %M1 = xor i1 %M, 1 - %N = icmp eq i32 %B, 47 - %O = and i1 %M1, %N - br i1 %O, label %T2, label %F2 - -; CHECK: Merge: -; CHECK-NOT: phi -; CHECK-NEXT: %v2 = call i32 @f2() - -T2: - %Q = zext i1 %M to i32 - ret i32 %Q - -F2: - ret i32 %B -; CHECK: F2: -; CHECK-NEXT: phi i32 -} - - - -; CHECK: @test10 -declare i32 @test10f1() -declare i32 @test10f2() -declare void @test10f3() - -;; Non-local condition threading. -define i32 @test10g(i1 %cond) { -; CHECK-LABEL: @test10g( -; CHECK-NEXT: br i1 %cond, label %T2, label %F2 - br i1 %cond, label %T1, label %F1 - -T1: - %v1 = call i32 @test10f1() - br label %Merge - -; CHECK: %v1 = call i32 @test10f1() -; CHECK-NEXT: call void @f3() -; CHECK-NEXT: ret i32 %v1 - -F1: - %v2 = call i32 @test10f2() - br label %Merge - -Merge: - %B = phi i32 [%v1, %T1], [%v2, %F1] - br i1 %cond, label %T2, label %F2 - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -} - - -; Impossible conditional constraints should get threaded. BB3 is dead here. -define i32 @test11(i32 %A) { -; CHECK-LABEL: @test11( -; CHECK-NEXT: icmp -; CHECK-NEXT: br i1 %tmp455, label %BB4, label %BB2 - %tmp455 = icmp eq i32 %A, 42 - br i1 %tmp455, label %BB1, label %BB2 - -BB2: -; CHECK: call i32 @f1() -; CHECK-NEXT: ret i32 %C - %C = call i32 @f1() - ret i32 %C - - -BB1: - %tmp459 = icmp eq i32 %A, 43 - br i1 %tmp459, label %BB3, label %BB4 - -BB3: - call i32 @f2() - ret i32 3 - -BB4: - call void @f3() - ret i32 4 -} - -;; Correlated value through boolean expression. GCC PR18046. -define void @test12(i32 %A) { -; CHECK-LABEL: @test12( -entry: - %cond = icmp eq i32 %A, 0 - br i1 %cond, label %bb, label %bb1 -; Should branch to the return block instead of through BB1. -; CHECK: entry: -; CHECK-NEXT: %cond = icmp eq i32 %A, 0 -; CHECK-NEXT: br i1 %cond, label %bb1, label %return - -bb: - %B = call i32 @test10f2() - br label %bb1 - -bb1: - %C = phi i32 [ %A, %entry ], [ %B, %bb ] - %cond4 = icmp eq i32 %C, 0 - br i1 %cond4, label %bb2, label %return - -; CHECK: bb1: -; CHECK-NEXT: %B = call i32 @test10f2() -; CHECK-NEXT: %cond4 = icmp eq i32 %B, 0 -; CHECK-NEXT: br i1 %cond4, label %bb2, label %return - -bb2: - %D = call i32 @test10f2() - ret void - -return: - ret void -} - - -;; Duplicate condition to avoid xor of cond. -;; rdar://7391699 -define i32 @test13(i1 %cond, i1 %cond2) { -Entry: -; CHECK-LABEL: @test13( - %v1 = call i32 @f1() - br i1 %cond, label %Merge, label %F1 - -F1: - br label %Merge - -Merge: - %B = phi i1 [true, %Entry], [%cond2, %F1] - %C = phi i32 [192, %Entry], [%v1, %F1] - %M = icmp eq i32 %C, 192 - %N = xor i1 %B, %M - br i1 %N, label %T2, label %F2 - -T2: - ret i32 123 - -F2: - ret i32 %v1 - -; CHECK: br i1 %cond, label %F2, label %Merge - -; CHECK: Merge: -; CHECK-NEXT: %M = icmp eq i32 %v1, 192 -; CHECK-NEXT: %N = xor i1 %cond2, %M -; CHECK-NEXT: br i1 %N, label %T2, label %F2 -} - -; CHECK-LABEL: @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-LABEL: @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: } -} - -;;; Verify that we can handle constraint propagation through cast. -define i32 @test16(i1 %cond) { -Entry: -; CHECK-LABEL: @test16( - br i1 %cond, label %Merge, label %F1 - -; CHECK: Entry: -; CHECK-NEXT: br i1 %cond, label %F2, label %Merge - -F1: - %v1 = call i32 @f1() - br label %Merge - -Merge: - %B = phi i32 [0, %Entry], [%v1, %F1] - %M = icmp eq i32 %B, 0 - %M1 = zext i1 %M to i32 - %N = icmp eq i32 %M1, 0 - br i1 %N, label %T2, label %F2 - -; CHECK: Merge: -; CHECK-NOT: phi -; CHECK-NEXT: %v1 = call i32 @f1() - -T2: - %Q = call i32 @f2() - ret i32 %Q - -F2: - ret i32 %B -; CHECK: F2: -; CHECK-NEXT: phi i32 -} - -; In this test we check that block duplication is inhibited by the presence -; of a function with the 'noduplicate' attribute. - -declare void @g() -declare void @j() -declare void @k() - -; CHECK-LABEL: define void @h(i32 %p) { -define void @h(i32 %p) { - %x = icmp ult i32 %p, 5 - br i1 %x, label %l1, label %l2 - -l1: - call void @j() - br label %l3 - -l2: - call void @k() - br label %l3 - -l3: -; CHECK: call void @g() [[$NOD:#[0-9]+]] -; CHECK-NOT: call void @g() [[$NOD]] - call void @g() noduplicate - %y = icmp ult i32 %p, 5 - br i1 %y, label %l4, label %l5 - -l4: - call void @j() - ret void - -l5: - call void @k() - ret void -; CHECK: } -} - -define i1 @trunc_switch(i1 %arg) { -; CHECK-LABEL: @trunc_switch -top: -; CHECK: br i1 %arg, label %exitA, label %exitB - br i1 %arg, label %common, label %B - -B: - br label %common - -common: - %phi = phi i8 [ 2, %B ], [ 1, %top ] - %trunc = trunc i8 %phi to i2 -; CHECK-NOT: switch - switch i2 %trunc, label %unreach [ - i2 1, label %exitA - i2 -2, label %exitB - ] - -unreach: - unreachable - -exitA: - ret i1 true - -exitB: - ret i1 false -} - -; CHECK-LABEL: define void @h_con(i32 %p) { -define void @h_con(i32 %p) { - %x = icmp ult i32 %p, 5 - br i1 %x, label %l1, label %l2 - -l1: - call void @j() - br label %l3 - -l2: - call void @k() - br label %l3 - -l3: -; CHECK: call void @g() [[$CON:#[0-9]+]] -; CHECK-NOT: call void @g() [[$CON]] - call void @g() convergent - %y = icmp ult i32 %p, 5 - br i1 %y, label %l4, label %l5 - -l4: - call void @j() - ret void - -l5: - call void @k() - ret void -; CHECK: } -} - - -; CHECK: attributes [[$NOD]] = { noduplicate } -; CHECK: attributes [[$CON]] = { convergent } diff --git a/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll b/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll deleted file mode 100644 index 5900350f540..00000000000 --- a/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll +++ /dev/null @@ -1,26 +0,0 @@ -; RUN: opt -S < %s -jump-threading | FileCheck %s -; CHECK-LABEL: @foo -; CHECK-NEXT: exit2: -; CHECK-NEXT: ret void -define void @foo() { -entry: - br label %bb1 - -entry2: - br label %bb1 - -bb1: - %a0 = phi i32 [ undef, %entry2 ], [ 0, %entry ] - %b = icmp ne i32 %a0, 0 - br i1 %b, label %bb2, label %exit2 - -bb2: - br label %exit1 - -exit1: - %a1 = phi i32 [ %a0, %bb2 ] - ret void - -exit2: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/branch-debug-info.ll b/llvm/test/Transforms/JumpThreading/branch-debug-info.ll deleted file mode 100644 index a5226483f67..00000000000 --- a/llvm/test/Transforms/JumpThreading/branch-debug-info.ll +++ /dev/null @@ -1,41 +0,0 @@ -; RUN: opt %s -debugify -jump-threading -S | FileCheck %s -; Tests Bug 37966 - -define void @test0(i32 %i) { -; CHECK-LABEL: @test0( -; CHECK: left: -; CHECK: br label %left, !dbg ![[DBG0:[0-9]+]] - entry: - %c0 = icmp ult i32 %i, 5 - br i1 %c0, label %left, label %right - - left: - br i1 %c0, label %left, label %right ; "line 3" to -debugify - - right: - ret void -} - -define void @test1(i32 %i, i32 %len) { -; CHECK-LABEL: @test1( -; CHECK: left: -; CHECK: br label %right, !dbg ![[DBG1:[0-9]+]] - entry: - %i.inc = add nuw i32 %i, 1 - %c0 = icmp ult i32 %i.inc, %len - br i1 %c0, label %left, label %right - - left: - %c1 = icmp ult i32 %i, %len - br i1 %c1, label %right, label %left0 ; "line 9" to -debugify - - left0: - ret void - - right: - ret void -} - -; CHECK-DAG: ![[DBG0]] = !DILocation(line: 3, -; CHECK-DAG: ![[DBG1]] = !DILocation(line: 9, - diff --git a/llvm/test/Transforms/JumpThreading/branch-no-const.ll b/llvm/test/Transforms/JumpThreading/branch-no-const.ll deleted file mode 100644 index 16867b07c2e..00000000000 --- a/llvm/test/Transforms/JumpThreading/branch-no-const.ll +++ /dev/null @@ -1,21 +0,0 @@ -; RUN: opt < %s -jump-threading -S | not grep phi - -declare i8 @mcguffin() - -define i32 @test(i1 %foo, i8 %b) { -entry: - %a = call i8 @mcguffin() - br i1 %foo, label %bb1, label %bb2 -bb1: - br label %jt -bb2: - br label %jt -jt: - %x = phi i8 [%a, %bb1], [%b, %bb2] - %A = icmp eq i8 %x, %a - br i1 %A, label %rt, label %rf -rt: - ret i32 7 -rf: - ret i32 8 -} diff --git a/llvm/test/Transforms/JumpThreading/callbr-edge-split.ll b/llvm/test/Transforms/JumpThreading/callbr-edge-split.ll deleted file mode 100644 index a341f73dee5..00000000000 --- a/llvm/test/Transforms/JumpThreading/callbr-edge-split.ll +++ /dev/null @@ -1,58 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -S -jump-threading | FileCheck %s - -; This test used to cause jump threading to try to split an edge of a callbr. - -@a = global i32 0 - -define i32 @c() { -; CHECK-LABEL: @c( -; CHECK-NEXT: entry: -; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @a -; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0 -; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]] -; CHECK: if.then: -; CHECK-NEXT: [[CALL:%.*]] = call i32 @b() -; CHECK-NEXT: [[PHITMP:%.*]] = icmp ne i32 [[CALL]], 0 -; CHECK-NEXT: br i1 [[PHITMP]], label [[IF_THEN2:%.*]], label [[IF_END4:%.*]] -; CHECK: if.else: -; CHECK-NEXT: callbr void asm sideeffect "", "X"(i8* blockaddress(@c, [[IF_THEN2]])) -; CHECK-NEXT: to label [[IF_END_THREAD:%.*]] [label %if.then2] -; CHECK: if.end.thread: -; CHECK-NEXT: br label [[IF_THEN2]] -; CHECK: if.then2: -; CHECK-NEXT: [[CALL3:%.*]] = call i32 @b() -; CHECK-NEXT: br label [[IF_END4]] -; CHECK: if.end4: -; CHECK-NEXT: ret i32 undef -; -entry: - %0 = load i32, i32* @a - %tobool = icmp eq i32 %0, 0 - br i1 %tobool, label %if.else, label %if.then - -if.then: ; preds = %entry - %call = call i32 @b() #2 - %phitmp = icmp ne i32 %call, 0 - br label %if.end - -if.else: ; preds = %entry - callbr void asm sideeffect "", "X"(i8* blockaddress(@c, %if.end)) #2 - to label %normal [label %if.end] - -normal: ; preds = %if.else - br label %if.end - -if.end: ; preds = %if.else, %normal, %if.then - %d.0 = phi i1 [ %phitmp, %if.then ], [ undef, %normal ], [ undef, %if.else ] - br i1 %d.0, label %if.then2, label %if.end4 - -if.then2: ; preds = %if.end - %call3 = call i32 @b() - br label %if.end4 - -if.end4: ; preds = %if.then2, %if.end - ret i32 undef -} - -declare i32 @b() diff --git a/llvm/test/Transforms/JumpThreading/combine-metadata.ll b/llvm/test/Transforms/JumpThreading/combine-metadata.ll deleted file mode 100644 index 6351236aebb..00000000000 --- a/llvm/test/Transforms/JumpThreading/combine-metadata.ll +++ /dev/null @@ -1,122 +0,0 @@ -; RUN: opt < %s -jump-threading -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" - -declare void @use(i32 *) - -; Check that we propagate nonnull to dominated loads, when we find an available -; loaded value. -; CHECK-LABEL: @test1( -; CHECK-LABEL: ret1: -; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr -; CHECK-NOT: !nonnull -; CHECK-NEXT: store i32 1, i32* %[[p1]] -; CHECK-NEXT: tail call void @use(i32* null) -; CHECK-NEXT: ret void - -; CHECK-LABEL: ret2: -; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr, !nonnull !0 -; CHECK: tail call void @use(i32* %[[p2]]) -; CHECK-NEXT: ret void -define void @test1(i32** %ptr, i1 %c) { - br i1 %c, label %d1, label %d2 - -d1: - %p1 = load i32*, i32** %ptr, !nonnull !0 - br label %d3 - -d2: - br label %d3 - -d3: - %pm = phi i32* [ null, %d2 ], [ %p1, %d1 ] - %p2 = load i32*, i32** %ptr - store i32 1, i32* %p2 - %c2 = icmp eq i32* %pm, null - br i1 %c2, label %ret1, label %ret2 - -ret1: - tail call void @use(i32* %pm) nounwind - ret void - -ret2: - tail call void @use(i32* %pm) nounwind - ret void -} - -; Check that we propagate nonnull to dominated loads, when we find an available -; loaded value. -; CHECK-LABEL: @test2( -; CHECK-LABEL: d3.thread: -; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr, !nonnull !0 -; CHECK-NEXT: store i32 1, i32* %[[p1]] -; CHECK-NEXT: br label %ret1 - -; CHECK-LABEL: d3: -; CHECK-NEXT: %[[p_cmp:.*]] = load i32*, i32** %ptr -; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr, !nonnull !0 -; CHECK-NEXT: store i32 1, i32* %[[p2]] -; CHECK-NEXT: icmp eq i32* %[[p_cmp]], null -define void @test2(i32** %ptr, i1 %c) { - br i1 %c, label %d1, label %d2 - -d1: - %p1 = load i32*, i32** %ptr - br label %d3 - -d2: - br label %d3 - -d3: - %pm = phi i32* [ null, %d2 ], [ %p1, %d1 ] - %p2 = load i32*, i32** %ptr, !nonnull !0 - store i32 1, i32* %p2 - %c2 = icmp eq i32* %pm, null - br i1 %c2, label %ret1, label %ret2 - -ret1: - tail call void @use(i32* %pm) nounwind - ret void - -ret2: - tail call void @use(i32* %pm) nounwind - ret void -} - -; Check that we do not propagate nonnull to loads predecessors that are combined -; to a PHI node. -; CHECK-LABEL: @test3( -; CHECK-LABEL: d1: -; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr -; CHECK-NOT: !nonnull - -; CHECK-LABEL: d2: -; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr -; CHECK-NOT: !nonnull - -; CHECK-LABEL: d3: -; CHECK-NEXT: phi i32* [ %[[p2]], %d2 ], [ %[[p1]], %d1 ] -define void @test3(i32** %ptr) { -d1: - %x = load i32*, i32** %ptr, !nonnull !0 - br label %d3 - -d2: - br label %d3 - -d3: - %y = load i32*, i32** %ptr - store i32 1, i32* %y - %c2 = icmp eq i32* %y, null - br i1 %c2, label %ret1, label %ret2 - -ret1: - ret void - -ret2: - ret void -} - - -!0 = !{} diff --git a/llvm/test/Transforms/JumpThreading/compare.ll b/llvm/test/Transforms/JumpThreading/compare.ll deleted file mode 100644 index 9b05b4496b0..00000000000 --- a/llvm/test/Transforms/JumpThreading/compare.ll +++ /dev/null @@ -1,30 +0,0 @@ -; There should be no phi nodes left. -; RUN: opt < %s -jump-threading -S | not grep "phi i32" - -declare i32 @f1() -declare i32 @f2() -declare void @f3() - -define i32 @test(i1 %cond) { - br i1 %cond, label %T1, label %F1 - -T1: - %v1 = call i32 @f1() - br label %Merge - -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: - %B = phi i32 [%v1, %T1], [12, %F1] - %A = icmp ne i32 %B, 42 - br i1 %A, label %T2, label %F2 - -T2: - call void @f3() - ret i32 1 - -F2: - ret i32 0 -} diff --git a/llvm/test/Transforms/JumpThreading/conservative-lvi.ll b/llvm/test/Transforms/JumpThreading/conservative-lvi.ll deleted file mode 100644 index 1ea8cdc4693..00000000000 --- a/llvm/test/Transforms/JumpThreading/conservative-lvi.ll +++ /dev/null @@ -1,58 +0,0 @@ -; RUN: opt -jump-threading -S %s | FileCheck %s - -; Check that we thread arg2neg -> checkpos -> end. -; -; LazyValueInfo would previously fail to analyze the value of %arg in arg2neg -; because its predecessing blocks (checkneg) hadn't been processed yet (PR21238) - -; CHECK-LABEL: @test_jump_threading -; CHECK: arg2neg: -; CHECK-NEXT: br i1 %arg1, label %end, label %checkpos.thread -; CHECK: checkpos.thread: -; CHECK-NEXT: br label %end - -define i32 @test_jump_threading(i1 %arg1, i32 %arg2) { -checkneg: - %cmp = icmp slt i32 %arg2, 0 - br i1 %cmp, label %arg2neg, label %checkpos - -arg2neg: - br i1 %arg1, label %end, label %checkpos - -checkpos: - %cmp2 = icmp sgt i32 %arg2, 0 - br i1 %cmp2, label %arg2pos, label %end - -arg2pos: - br label %end - -end: - %0 = phi i32 [ 1, %arg2neg ], [ 2, %checkpos ], [ 3, %arg2pos ] - ret i32 %0 -} - - -; arg2neg has an edge back to itself. If LazyValueInfo is not careful when -; visiting predecessors, it could get into an infinite loop. - -; CHECK-LABEL: test_infinite_loop - -define i32 @test_infinite_loop(i1 %arg1, i32 %arg2) { -checkneg: - %cmp = icmp slt i32 %arg2, 0 - br i1 %cmp, label %arg2neg, label %checkpos - -arg2neg: - br i1 %arg1, label %arg2neg, label %checkpos - -checkpos: - %cmp2 = icmp sgt i32 %arg2, 0 - br i1 %cmp2, label %arg2pos, label %end - -arg2pos: - br label %end - -end: - %0 = phi i32 [ 2, %checkpos ], [ 3, %arg2pos ] - ret i32 %0 -} diff --git a/llvm/test/Transforms/JumpThreading/crash.ll b/llvm/test/Transforms/JumpThreading/crash.ll deleted file mode 100644 index 01bec4b2c2d..00000000000 --- a/llvm/test/Transforms/JumpThreading/crash.ll +++ /dev/null @@ -1,626 +0,0 @@ -; RUN: opt < %s -jump-threading -S | FileCheck %s -; PR2285 -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" -target triple = "x86_64-unknown-linux-gnu" - %struct.system__secondary_stack__mark_id = type { i64, i64 } - -define void @_ada_c35507b() { -entry: - br label %bb - -bb: ; preds = %bb13, %entry - %ch.0 = phi i8 [ 0, %entry ], [ 0, %bb13 ] ; <i8> [#uses=1] - %tmp11 = icmp ugt i8 %ch.0, 31 ; <i1> [#uses=1] - %tmp120 = call %struct.system__secondary_stack__mark_id @system__secondary_stack__ss_mark( ) ; <%struct.system__secondary_stack__mark_id> [#uses=1] - br i1 %tmp11, label %bb110, label %bb13 - -bb13: ; preds = %bb - br label %bb - -bb110: ; preds = %bb - %mrv_gr124 = extractvalue %struct.system__secondary_stack__mark_id %tmp120, 1 ; <i64> [#uses=0] - unreachable -} - -declare %struct.system__secondary_stack__mark_id @system__secondary_stack__ss_mark() - - - -define fastcc void @findratio(double* nocapture %res1, double* nocapture %res2) nounwind ssp { -entry: - br label %bb12 - -bb6.us: - %tmp = icmp eq i32 undef, undef - %tmp1 = fsub double undef, undef - %tmp2 = fcmp ult double %tmp1, 0.000000e+00 - br i1 %tmp, label %bb6.us, label %bb13 - - -bb12: - %tmp3 = fcmp ult double undef, 0.000000e+00 - br label %bb13 - -bb13: - %.lcssa31 = phi double [ undef, %bb12 ], [ %tmp1, %bb6.us ] - %.lcssa30 = phi i1 [ %tmp3, %bb12 ], [ %tmp2, %bb6.us ] - br i1 %.lcssa30, label %bb15, label %bb61 - -bb15: - %tmp4 = fsub double -0.000000e+00, %.lcssa31 - ret void - - -bb61: - ret void -} - - -; PR5258 -define i32 @test(i1 %cond, i1 %cond2, i32 %a) { -A: - br i1 %cond, label %F, label %A1 -F: - br label %A1 - -A1: - %d = phi i1 [false, %A], [true, %F] - %e = add i32 %a, %a - br i1 %d, label %B, label %G - -G: - br i1 %cond2, label %B, label %D - -B: - %f = phi i32 [%e, %G], [%e, %A1] - %b = add i32 0, 0 - switch i32 %a, label %C [ - i32 7, label %D - i32 8, label %D - i32 9, label %D - ] - -C: - br label %D - -D: - %c = phi i32 [%e, %B], [%e, %B], [%e, %B], [%f, %C], [%e, %G] - ret i32 %c -E: - ret i32 412 -} - - -define i32 @test2() nounwind { -entry: - br i1 true, label %decDivideOp.exit, label %bb7.i - -bb7.i: ; preds = %bb7.i, %entry - br label %bb7.i - -decDivideOp.exit: ; preds = %entry - ret i32 undef -} - - -; PR3298 - -define i32 @test3(i32 %p_79, i32 %p_80) nounwind { -entry: - br label %bb7 - -bb1: ; preds = %bb2 - br label %bb2 - -bb2: ; preds = %bb7, %bb1 - %l_82.0 = phi i8 [ 0, %bb1 ], [ %l_82.1, %bb7 ] ; <i8> [#uses=3] - br i1 true, label %bb3, label %bb1 - -bb3: ; preds = %bb2 - %0 = icmp eq i32 %p_80_addr.1, 0 ; <i1> [#uses=1] - br i1 %0, label %bb7, label %bb6 - -bb5: ; preds = %bb6 - %1 = icmp eq i8 %l_82.0, 0 ; <i1> [#uses=1] - br i1 %1, label %bb1.i, label %bb.i - -bb.i: ; preds = %bb5 - br label %safe_div_func_char_s_s.exit - -bb1.i: ; preds = %bb5 - br label %safe_div_func_char_s_s.exit - -safe_div_func_char_s_s.exit: ; preds = %bb1.i, %bb.i - br label %bb6 - -bb6: ; preds = %safe_div_func_char_s_s.exit, %bb3 - %p_80_addr.0 = phi i32 [ %p_80_addr.1, %bb3 ], [ 1, %safe_div_func_char_s_s.exit ] ; <i32> [#uses=2] - %2 = icmp eq i32 %p_80_addr.0, 0 ; <i1> [#uses=1] - br i1 %2, label %bb7, label %bb5 - -bb7: ; preds = %bb6, %bb3, %entry - %l_82.1 = phi i8 [ 1, %entry ], [ %l_82.0, %bb3 ], [ %l_82.0, %bb6 ] ; <i8> [#uses=2] - %p_80_addr.1 = phi i32 [ 0, %entry ], [ %p_80_addr.1, %bb3 ], [ %p_80_addr.0, %bb6 ] ; <i32> [#uses=4] - %3 = icmp eq i32 %p_80_addr.1, 0 ; <i1> [#uses=1] - br i1 %3, label %bb8, label %bb2 - -bb8: ; preds = %bb7 - %4 = sext i8 %l_82.1 to i32 ; <i32> [#uses=0] - ret i32 0 -} - - -; PR3353 - -define i32 @test4(i8 %X) { -entry: - %Y = add i8 %X, 1 - %Z = add i8 %Y, 1 - br label %bb33.i - -bb33.i: ; preds = %bb33.i, %bb32.i - switch i8 %Y, label %bb32.i [ - i8 39, label %bb35.split.i - i8 13, label %bb33.i - ] - -bb35.split.i: - ret i32 5 -bb32.i: - ret i32 1 -} - - -define fastcc void @test5(i1 %tmp, i32 %tmp1) nounwind ssp { -entry: - br i1 %tmp, label %bb12, label %bb13 - - -bb12: - br label %bb13 - -bb13: - %.lcssa31 = phi i32 [ undef, %bb12 ], [ %tmp1, %entry ] - %A = and i1 undef, undef - br i1 %A, label %bb15, label %bb61 - -bb15: - ret void - - -bb61: - ret void -} - - -; PR5640 -define fastcc void @test6(i1 %tmp, i1 %tmp1) nounwind ssp { -entry: - br i1 %tmp, label %bb12, label %bb14 - -bb12: - br label %bb14 - -bb14: - %A = phi i1 [ %A, %bb13 ], [ true, %bb12 ], [%tmp1, %entry] - br label %bb13 - -bb13: - br i1 %A, label %bb14, label %bb61 - - -bb61: - ret void -} - - -; PR5698 -define void @test7(i32 %x) { -entry: - br label %tailrecurse - -tailrecurse: - switch i32 %x, label %return [ - i32 2, label %bb2 - i32 3, label %bb - ] - -bb: - switch i32 %x, label %return [ - i32 2, label %bb2 - i32 3, label %tailrecurse - ] - -bb2: - ret void - -return: - ret void -} - -; PR6119 -define i32 @test8(i32 %action) nounwind { -entry: - switch i32 %action, label %lor.rhs [ - i32 1, label %if.then - i32 0, label %lor.end - ] - -if.then: ; preds = %for.cond, %lor.end, %entry - ret i32 undef - -lor.rhs: ; preds = %entry - br label %lor.end - -lor.end: ; preds = %lor.rhs, %entry - %cmp103 = xor i1 undef, undef ; <i1> [#uses=1] - br i1 %cmp103, label %for.cond, label %if.then - -for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body - -for.body: ; preds = %for.cond - br label %for.cond -} - -; PR6119 -define i32 @test9(i32 %action) nounwind { -entry: - switch i32 %action, label %lor.rhs [ - i32 1, label %if.then - i32 0, label %lor.end - ] - -if.then: ; preds = %for.cond, %lor.end, %entry - ret i32 undef - -lor.rhs: ; preds = %entry - br label %lor.end - -lor.end: ; preds = %lor.rhs, %entry - %0 = phi i1 [ undef, %lor.rhs ], [ true, %entry ] ; <i1> [#uses=1] - %cmp103 = xor i1 undef, %0 ; <i1> [#uses=1] - br i1 %cmp103, label %for.cond, label %if.then - -for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body - -for.body: ; preds = %for.cond - br label %for.cond -} - -; PR6119 -define i32 @test10(i32 %action, i32 %type) nounwind { -entry: - %cmp2 = icmp eq i32 %type, 0 ; <i1> [#uses=1] - switch i32 %action, label %lor.rhs [ - i32 1, label %if.then - i32 0, label %lor.end - ] - -if.then: ; preds = %for.cond, %lor.end, %entry - ret i32 undef - -lor.rhs: ; preds = %entry - %cmp101 = icmp eq i32 %action, 2 ; <i1> [#uses=1] - br label %lor.end - -lor.end: ; preds = %lor.rhs, %entry - %0 = phi i1 [ %cmp101, %lor.rhs ], [ true, %entry ] ; <i1> [#uses=1] - %cmp103 = xor i1 %cmp2, %0 ; <i1> [#uses=1] - br i1 %cmp103, label %for.cond, label %if.then - -for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body - -for.body: ; preds = %for.cond - br label %for.cond -} - - -; PR6305 -define void @test11() nounwind { -entry: - br label %A - -A: ; preds = %entry - call void undef(i64 ptrtoint (i8* blockaddress(@test11, %A) to i64)) nounwind - unreachable -} - -; PR6743 -define void @test12() nounwind ssp { -entry: - br label %lbl_51 - -lbl_51: ; preds = %if.then, %entry - %tmp3 = phi i1 [ false, %if.then ], [ undef, %entry ] ; <i1> [#uses=2] - br i1 %tmp3, label %if.end12, label %if.then - -if.then: ; preds = %lbl_51 - br i1 %tmp3, label %lbl_51, label %if.end12 - -if.end12: ; preds = %if.then, %lbl_51 - ret void -} - - - -; PR7356 -define i32 @test13(i32* %P, i8* %Ptr) { -entry: - indirectbr i8* %Ptr, [label %BrBlock, label %B2] - -B2: - store i32 4, i32 *%P - br label %BrBlock - -BrBlock: - %L = load i32, i32* %P - %C = icmp eq i32 %L, 42 - br i1 %C, label %T, label %F - -T: - ret i32 123 -F: - ret i32 1422 -} - - -; PR7498 -define void @test14() nounwind { -entry: - %cmp33 = icmp slt i8 undef, 0 ; <i1> [#uses=1] - %tobool = icmp eq i8 undef, 0 ; <i1> [#uses=1] - br i1 %tobool, label %land.end69, label %land.rhs - -land.rhs: ; preds = %entry - br label %land.end69 - -land.end69: ; preds = %land.rhs, %entry - %0 = phi i1 [ undef, %land.rhs ], [ true, %entry ] ; <i1> [#uses=1] - %cmp71 = or i1 true, %0 ; <i1> [#uses=1] - %cmp73 = xor i1 %cmp33, %cmp71 ; <i1> [#uses=1] - br i1 %cmp73, label %if.then, label %if.end - -if.then: ; preds = %land.end69 - ret void - -if.end: ; preds = %land.end69 - ret void -} - -; PR7647 -define void @test15() nounwind { -entry: - ret void - -if.then237: - br label %lbl_664 - -lbl_596: ; preds = %lbl_664, %for.end37 - store volatile i64 undef, i64* undef, align 4 - br label %for.cond111 - -for.cond111: ; preds = %safe_sub_func_int64_t_s_s.exit, %lbl_596 - %storemerge = phi i8 [ undef, %cond.true.i100 ], [ 22, %lbl_596 ] ; <i8> [#uses=1] - %l_678.5 = phi i64 [ %l_678.3, %cond.true.i100 ], [ undef, %lbl_596 ] ; <i64> [#uses=2] - %cmp114 = icmp slt i8 %storemerge, -2 ; <i1> [#uses=1] - br i1 %cmp114, label %lbl_664, label %if.end949 - -lbl_664: ; preds = %for.end1058, %if.then237, %for.cond111 - %l_678.3 = phi i64 [ %l_678.5, %for.cond111 ], [ %l_678.2, %for.cond1035 ], [ 5, %if.then237 ] ; <i64> [#uses=1] - %tobool118 = icmp eq i32 undef, 0 ; <i1> [#uses=1] - br i1 %tobool118, label %cond.true.i100, label %lbl_596 - -cond.true.i100: ; preds = %for.inc120 - br label %for.cond111 - -lbl_709: - br label %if.end949 - -for.cond603: ; preds = %for.body607, %if.end336 - br i1 undef, label %for.cond603, label %if.end949 - -if.end949: ; preds = %for.cond603, %lbl_709, %for.cond111 - %l_678.2 = phi i64 [ %l_678.5, %for.cond111 ], [ undef, %lbl_709 ], [ 5, %for.cond603 ] ; <i64> [#uses=1] - br label %for.body1016 - -for.body1016: ; preds = %for.cond1012 - br label %for.body1016 - -for.cond1035: ; preds = %for.inc1055, %if.then1026 - br i1 undef, label %for.cond1040, label %lbl_664 - -for.cond1040: ; preds = %for.body1044, %for.cond1035 - 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 -} - -; PR 8247 -%struct.S1 = type { i8, i8 } -@func_89.l_245 = internal constant %struct.S1 { i8 33, i8 6 }, align 1 -define void @func_89(i16 zeroext %p_90, %struct.S1* nocapture %p_91, i32* nocapture %p_92) nounwind ssp { -entry: - store i32 0, i32* %p_92, align 4 - br i1 false, label %lbl_260, label %if.else - -if.else: ; preds = %entry - br label %for.cond - -for.cond: ; preds = %lbl_260, %if.else - %l_245.0 = phi i16 [ %l_245.1, %lbl_260 ], [ 33, %if.else ] - %l_261.0 = phi i32 [ %and, %lbl_260 ], [ 255, %if.else ] - %tobool21 = icmp ult i16 %l_245.0, 256 - br i1 %tobool21, label %if.end, label %lbl_260 - -lbl_260: ; preds = %for.cond, %entry - %l_245.1 = phi i16 [ 1569, %entry ], [ %l_245.0, %for.cond ] - %l_261.1 = phi i32 [ 255, %entry ], [ %l_261.0, %for.cond ] - %and = and i32 %l_261.1, 1 - br label %for.cond - -if.end: ; preds = %for.cond - ret void -} - -define void @PR14233(i1 %cmp, i1 %cmp2, i1 %cmp3, i1 %cmp4) { -entry: - br i1 %cmp, label %cond.true, label %cond.false - -cond.true: - br label %if.end - -cond.false: - br label %if.end - -if.end: - %A = phi i64 [ 0, %cond.true ], [ 1, %cond.false ] - br i1 %cmp2, label %bb, label %if.end2 - -bb: - br label %if.end2 - -if.end2: - %B = phi i64 [ ptrtoint (i8* ()* @PR14233.f1 to i64), %bb ], [ %A, %if.end ] - %cmp.ptr = icmp eq i64 %B, ptrtoint (i8* ()* @PR14233.f2 to i64) - br i1 %cmp.ptr, label %cond.true2, label %if.end3 - -cond.true2: - br i1 %cmp3, label %bb2, label %ur - -bb2: - br i1 %cmp4, label %if.end4, label %if.end3 - -if.end4: - unreachable - -if.end3: - %cmp.ptr2 = icmp eq i64 %B, ptrtoint (i8* ()* @PR14233.f2 to i64) - br i1 %cmp.ptr2, label %ur, label %if.then601 - -if.then601: - %C = icmp eq i64 %B, 0 - br i1 %C, label %bb3, label %bb4 - -bb3: - unreachable - -bb4: - unreachable - -ur: - unreachable -} - -declare i8* @PR14233.f1() - -declare i8* @PR14233.f2() - -; Make sure the following compiles in a sane amount of time, as opposed -; to taking exponential time. -; (CHECK to make sure the condition doesn't get simplified somehow; -; if it does, the testcase will need to be revised.) -; CHECK-LABEL: define void @almost_infinite_loop -; CHECK: %x39 = or i1 %x38, %x38 -; CHECK: br i1 %x39, label %dest1, label %dest2 -define void @almost_infinite_loop(i1 %x0) { -entry: - br label %if.then57.i - -if.then57.i: - %x1 = or i1 %x0, %x0 - %x2 = or i1 %x1, %x1 - %x3 = or i1 %x2, %x2 - %x4 = or i1 %x3, %x3 - %x5 = or i1 %x4, %x4 - %x6 = or i1 %x5, %x5 - %x7 = or i1 %x6, %x6 - %x8 = or i1 %x7, %x7 - %x9 = or i1 %x8, %x8 - %x10 = or i1 %x9, %x9 - %x11 = or i1 %x10, %x10 - %x12 = or i1 %x11, %x11 - %x13 = or i1 %x12, %x12 - %x14 = or i1 %x13, %x13 - %x15 = or i1 %x14, %x14 - %x16 = or i1 %x15, %x15 - %x17 = or i1 %x16, %x16 - %x18 = or i1 %x17, %x17 - %x19 = or i1 %x18, %x18 - %x20 = or i1 %x19, %x19 - %x21 = or i1 %x20, %x20 - %x22 = or i1 %x21, %x21 - %x23 = or i1 %x22, %x22 - %x24 = or i1 %x23, %x23 - %x25 = or i1 %x24, %x24 - %x26 = or i1 %x25, %x25 - %x27 = or i1 %x26, %x26 - %x28 = or i1 %x27, %x27 - %x29 = or i1 %x28, %x28 - %x30 = or i1 %x29, %x29 - %x31 = or i1 %x30, %x30 - %x32 = or i1 %x31, %x31 - %x33 = or i1 %x32, %x32 - %x34 = or i1 %x33, %x33 - %x35 = or i1 %x34, %x34 - %x36 = or i1 %x35, %x35 - %x37 = or i1 %x36, %x36 - %x38 = or i1 %x37, %x37 - %x39 = or i1 %x38, %x38 - br i1 %x39, label %dest1, label %dest2 - -dest1: - unreachable - -dest2: - unreachable -} diff --git a/llvm/test/Transforms/JumpThreading/ddt-crash.ll b/llvm/test/Transforms/JumpThreading/ddt-crash.ll deleted file mode 100644 index a5cf24d354c..00000000000 --- a/llvm/test/Transforms/JumpThreading/ddt-crash.ll +++ /dev/null @@ -1,265 +0,0 @@ -; RUN: opt < %s -jump-threading -disable-output - -%struct.ham = type { i8, i8, i16, i32 } -%struct.zot = type { i32 (...)** } -%struct.quux.0 = type { %struct.wombat } -%struct.wombat = type { %struct.zot } - -@global = external global %struct.ham*, align 8 -@global.1 = external constant i8* - -declare i32 @wombat.2() - -define void @blam() { -bb: - %tmp = load i32, i32* undef - %tmp1 = icmp eq i32 %tmp, 0 - br i1 %tmp1, label %bb11, label %bb2 - -bb2: - %tmp3 = tail call i32 @wombat.2() - switch i32 %tmp3, label %bb4 [ - i32 0, label %bb5 - i32 1, label %bb7 - i32 2, label %bb7 - i32 3, label %bb11 - ] - -bb4: - br label %bb7 - -bb5: - %tmp6 = tail call i32 @wombat.2() - br label %bb7 - -bb7: - %tmp8 = phi i32 [ 0, %bb5 ], [ 1, %bb4 ], [ 2, %bb2 ], [ 2, %bb2 ] - %tmp9 = icmp eq i32 %tmp8, 0 - br i1 %tmp9, label %bb11, label %bb10 - -bb10: - ret void - -bb11: - ret void -} - -define void @spam(%struct.ham* %arg) { -bb: - %tmp = load i8, i8* undef, align 8 - switch i8 %tmp, label %bb11 [ - i8 1, label %bb11 - i8 2, label %bb11 - i8 3, label %bb1 - i8 4, label %bb1 - ] - -bb1: - br label %bb2 - -bb2: - %tmp3 = phi i32 [ 0, %bb1 ], [ %tmp3, %bb8 ] - br label %bb4 - -bb4: - %tmp5 = load i8, i8* undef, align 8 - switch i8 %tmp5, label %bb11 [ - i8 0, label %bb11 - i8 1, label %bb10 - i8 2, label %bb10 - i8 3, label %bb6 - i8 4, label %bb6 - ] - -bb6: - br label %bb7 - -bb7: - br i1 undef, label %bb8, label %bb10 - -bb8: - %tmp9 = icmp eq %struct.ham* undef, %arg - br i1 %tmp9, label %bb10, label %bb2 - -bb10: - switch i32 %tmp3, label %bb4 [ - i32 0, label %bb14 - i32 1, label %bb11 - i32 2, label %bb12 - ] - -bb11: - unreachable - -bb12: - %tmp13 = load %struct.ham*, %struct.ham** undef - br label %bb14 - -bb14: - %tmp15 = phi %struct.ham* [ %tmp13, %bb12 ], [ null, %bb10 ] - br label %bb16 - -bb16: - %tmp17 = load i8, i8* undef, align 8 - switch i8 %tmp17, label %bb11 [ - i8 0, label %bb11 - i8 11, label %bb18 - i8 12, label %bb18 - ] - -bb18: - br label %bb19 - -bb19: - br label %bb20 - -bb20: - %tmp21 = load %struct.ham*, %struct.ham** undef - switch i8 undef, label %bb22 [ - i8 0, label %bb4 - i8 11, label %bb10 - i8 12, label %bb10 - ] - -bb22: - br label %bb23 - -bb23: - %tmp24 = icmp eq %struct.ham* %tmp21, null - br i1 %tmp24, label %bb35, label %bb25 - -bb25: - %tmp26 = icmp eq %struct.ham* %tmp15, null - br i1 %tmp26, label %bb34, label %bb27 - -bb27: - %tmp28 = load %struct.ham*, %struct.ham** undef - %tmp29 = icmp eq %struct.ham* %tmp28, %tmp21 - br i1 %tmp29, label %bb35, label %bb30 - -bb30: - br label %bb31 - -bb31: - %tmp32 = load i8, i8* undef, align 8 - %tmp33 = icmp eq i8 %tmp32, 0 - br i1 %tmp33, label %bb31, label %bb34 - -bb34: - br label %bb35 - -bb35: - %tmp36 = phi i1 [ true, %bb34 ], [ false, %bb23 ], [ true, %bb27 ] - br label %bb37 - -bb37: - %tmp38 = icmp eq %struct.ham* %tmp15, null - br i1 %tmp38, label %bb39, label %bb41 - -bb39: - %tmp40 = load %struct.ham*, %struct.ham** @global - br label %bb41 - -bb41: - %tmp42 = select i1 %tmp36, %struct.ham* undef, %struct.ham* undef - ret void -} - -declare i32 @foo(...) - -define void @zot() align 2 personality i8* bitcast (i32 (...)* @foo to i8*) { -bb: - invoke void @bar() - to label %bb1 unwind label %bb3 - -bb1: - invoke void @bar() - to label %bb2 unwind label %bb4 - -bb2: - invoke void @bar() - to label %bb6 unwind label %bb17 - -bb3: - %tmp = landingpad { i8*, i32 } - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - unreachable - -bb4: - %tmp5 = landingpad { i8*, i32 } - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - unreachable - -bb6: - invoke void @bar() - to label %bb7 unwind label %bb19 - -bb7: - invoke void @bar() - to label %bb10 unwind label %bb8 - -bb8: - %tmp9 = landingpad { i8*, i32 } - cleanup - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - unreachable - -bb10: - %tmp11 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8 - %tmp12 = invoke i32 %tmp11(%struct.zot* nonnull undef) - to label %bb13 unwind label %bb21 - -bb13: - invoke void @bar() - to label %bb14 unwind label %bb23 - -bb14: - %tmp15 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8 - %tmp16 = invoke i32 %tmp15(%struct.zot* nonnull undef) - to label %bb26 unwind label %bb23 - -bb17: - %tmp18 = landingpad { i8*, i32 } - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - unreachable - -bb19: - %tmp20 = landingpad { i8*, i32 } - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - unreachable - -bb21: - %tmp22 = landingpad { i8*, i32 } - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - unreachable - -bb23: - %tmp24 = phi %struct.quux.0* [ null, %bb26 ], [ null, %bb14 ], [ undef, %bb13 ] - %tmp25 = landingpad { i8*, i32 } - catch i8* bitcast (i8** @global.1 to i8*) - catch i8* null - br label %bb30 - -bb26: - %tmp27 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8 - %tmp28 = invoke i32 %tmp27(%struct.zot* nonnull undef) - to label %bb29 unwind label %bb23 - -bb29: - unreachable - -bb30: - %tmp31 = icmp eq %struct.quux.0* %tmp24, null - br i1 %tmp31, label %bb32, label %bb29 - -bb32: - unreachable -} - -declare void @bar() diff --git a/llvm/test/Transforms/JumpThreading/ddt-crash2.ll b/llvm/test/Transforms/JumpThreading/ddt-crash2.ll deleted file mode 100644 index 92bea6a7dff..00000000000 --- a/llvm/test/Transforms/JumpThreading/ddt-crash2.ll +++ /dev/null @@ -1,40 +0,0 @@ -; RUN: opt < %s -jump-threading -disable-output - -%struct.aaa = type { i8 } - -define void @chrome(%struct.aaa* noalias sret %arg) local_unnamed_addr #0 align 2 personality i8* bitcast (i32 (...)* @chrome2 to i8*) { -bb: - %tmp = load i32, i32* undef, align 4 - %tmp1 = icmp eq i32 %tmp, 0 - br i1 %tmp1, label %bb2, label %bb13 - -bb2: - %tmp3 = getelementptr inbounds %struct.aaa, %struct.aaa* %arg, i64 0, i32 0 - %tmp4 = load i8, i8* %tmp3, align 1 - %tmp5 = icmp eq i8 %tmp4, 0 - br i1 %tmp5, label %bb6, label %bb7 - -bb6: - store i8 0, i8* %tmp3, align 1 - br label %bb7 - -bb7: - %tmp8 = load i8, i8* %tmp3, align 1 - %tmp9 = icmp ne i8 %tmp8, 0 - %tmp10 = select i1 %tmp9, i1 true, i1 false - br i1 %tmp10, label %bb12, label %bb11 - -bb11: - br label %bb12 - -bb12: - br i1 %tmp9, label %bb14, label %bb13 - -bb13: - unreachable - -bb14: - ret void -} - -declare i32 @chrome2(...) diff --git a/llvm/test/Transforms/JumpThreading/ddt-crash3.ll b/llvm/test/Transforms/JumpThreading/ddt-crash3.ll deleted file mode 100644 index 50ac86a3fb5..00000000000 --- a/llvm/test/Transforms/JumpThreading/ddt-crash3.ll +++ /dev/null @@ -1,43 +0,0 @@ -; RUN: opt < %s -jump-threading -disable-output -verify-dom-info - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -@global = external local_unnamed_addr global i64, align 8 -@global.1 = external local_unnamed_addr global i64, align 8 -@global.2 = external local_unnamed_addr global i64, align 8 - -; Function Attrs: norecurse noreturn nounwind uwtable -define void @hoge() local_unnamed_addr #0 { -bb: - br label %bb1 - -bb1: ; preds = %bb26, %bb - %tmp = load i64, i64* @global, align 8, !tbaa !1 - %tmp2 = icmp eq i64 %tmp, 0 - br i1 %tmp2, label %bb27, label %bb3 - -bb3: ; preds = %bb1 - %tmp4 = load i64, i64* @global.1, align 8, !tbaa !1 - %tmp5 = icmp eq i64 %tmp4, 0 - br i1 %tmp5, label %bb23, label %bb23 - -bb23: ; preds = %bb3, %bb3 - br label %bb26 - -bb26: ; preds = %bb27, %bb23 - br label %bb1 - -bb27: ; preds = %bb1 - br label %bb26 -} - -attributes #0 = { norecurse noreturn nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.ident = !{!0} - -!0 = !{!"clang version 7.0.0 "} -!1 = !{!2, !2, i64 0} -!2 = !{!"long", !3, i64 0} -!3 = !{!"omnipotent char", !4, i64 0} -!4 = !{!"Simple C/C++ TBAA"} diff --git a/llvm/test/Transforms/JumpThreading/ddt-crash4.ll b/llvm/test/Transforms/JumpThreading/ddt-crash4.ll deleted file mode 100644 index 9bf08395d66..00000000000 --- a/llvm/test/Transforms/JumpThreading/ddt-crash4.ll +++ /dev/null @@ -1,75 +0,0 @@ -; RUN: opt < %s -jump-threading -disable-output -verify-dom-info -@global = external global i64, align 8 - -define void @f() { -bb: - br label %bb1 - -bb1: - %tmp = load i64, i64* @global, align 8 - %tmp2 = icmp eq i64 %tmp, 0 - br i1 %tmp2, label %bb27, label %bb3 - -bb3: - %tmp4 = load i64, i64* @global, align 8 - %tmp5 = icmp eq i64 %tmp4, 0 - br i1 %tmp5, label %bb6, label %bb7 - -bb6: - br label %bb7 - -bb7: - %tmp8 = phi i1 [ true, %bb3 ], [ undef, %bb6 ] - %tmp9 = select i1 %tmp8, i64 %tmp4, i64 0 - br i1 false, label %bb10, label %bb23 - -bb10: - %tmp11 = load i64, i64* @global, align 8 - %tmp12 = icmp slt i64 %tmp11, 5 - br i1 %tmp12, label %bb13, label %bb17 - -bb13: - br label %bb14 - -bb14: - br i1 undef, label %bb15, label %bb16 - -bb15: - unreachable - -bb16: - br label %bb10 - -bb17: - br label %bb18 - -bb18: - br i1 undef, label %bb22, label %bb13 - -bb19: - br i1 undef, label %bb20, label %bb21 - -bb20: - unreachable - -bb21: - br label %bb18 - -bb22: - br label %bb23 - -bb23: - br i1 undef, label %bb24, label %bb13 - -bb24: - br i1 undef, label %bb26, label %bb25 - -bb25: - br label %bb19 - -bb26: - br label %bb1 - -bb27: - br label %bb24 -} diff --git a/llvm/test/Transforms/JumpThreading/degenerate-phi.ll b/llvm/test/Transforms/JumpThreading/degenerate-phi.ll deleted file mode 100644 index 2905b43af72..00000000000 --- a/llvm/test/Transforms/JumpThreading/degenerate-phi.ll +++ /dev/null @@ -1,24 +0,0 @@ -; RUN: opt -jump-threading -disable-output < %s -; PR9112 - -; This is actually a test for value tracking. Jump threading produces -; "%phi = phi i16" when it removes all edges leading to %unreachable. -; The .ll parser won't let us write that directly since it's invalid code. - -define void @func() nounwind { -entry: - br label %bb - -bb: - br label %bb - -unreachable: - %phi = phi i16 [ %add, %unreachable ], [ 0, %next ] - %add = add i16 0, %phi - %cmp = icmp slt i16 %phi, 0 - br i1 %cmp, label %unreachable, label %next - -next: - br label %unreachable -} - diff --git a/llvm/test/Transforms/JumpThreading/fold-not-thread.ll b/llvm/test/Transforms/JumpThreading/fold-not-thread.ll deleted file mode 100644 index 85cdcc0d9b3..00000000000 --- a/llvm/test/Transforms/JumpThreading/fold-not-thread.ll +++ /dev/null @@ -1,246 +0,0 @@ -; RUN: opt -jump-threading -S -verify < %s | FileCheck %s - -declare i32 @f1() -declare i32 @f2() -declare void @f3() -declare void @f4(i32) - - -; Make sure we update the phi node properly. -; -; CHECK-LABEL: define void @test_br_folding_not_threading_update_phi( -; CHECK: br label %L1 -; Make sure we update the phi node properly here, i.e. we only have 2 predecessors, entry and L0 -; CHECK: %res.0 = phi i32 [ 0, %L0 ], [ 1, %entry ] -define void @test_br_folding_not_threading_update_phi(i32 %val) nounwind { -entry: - %cmp = icmp eq i32 %val, 32 - br i1 %cmp, label %L0, label %L1 -L0: - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - switch i32 %val, label %L2 [ - i32 0, label %L1 - i32 32, label %L1 - ] - -L1: - %res.0 = phi i32 [ 0, %L0 ], [ 0, %L0 ], [1, %entry] - call void @f4(i32 %res.0) - ret void -L2: - call void @f3() - ret void -} - -; Make sure we can fold this branch ... We will not be able to thread it as -; L0 is too big to duplicate. L2 is the unreachable block here. -; -; CHECK-LABEL: @test_br_folding_not_threading( -; CHECK: L1: -; CHECK: call i32 @f2() -; CHECK: call void @f3() -; CHECK-NEXT: ret void -; CHECK-NOT: br -; CHECK: L3: -define void @test_br_folding_not_threading(i1 %cond) nounwind { -entry: - br i1 %cond, label %L0, label %L3 -L0: - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - br i1 %cond, label %L1, label %L2 - -L1: - call void @f3() - ret void -L2: - call void @f3() - ret void -L3: - call void @f3() - ret void -} - - -; Make sure we can fold this branch ... We will not be able to thread it as -; L0 is too big to duplicate. L2 is the unreachable block here. -; With more than 1 predecessors. -; -; CHECK-LABEL: @test_br_folding_not_threading_multiple_preds( -; CHECK: L1: -; CHECK: call i32 @f2() -; CHECK: call void @f3() -; CHECK-NEXT: ret void -; CHECK-NOT: br -; CHECK: L3: -define void @test_br_folding_not_threading_multiple_preds(i1 %condx, i1 %cond) nounwind { -entry: - br i1 %condx, label %X0, label %X1 - -X0: - br i1 %cond, label %L0, label %L3 - -X1: - br i1 %cond, label %L0, label %L3 - -L0: - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - br i1 %cond, label %L1, label %L2 - -L1: - call void @f3() - ret void -L2: - call void @f3() - ret void -L3: - call void @f3() - ret void -} - -; Make sure we can do the RAUW for %add... -; -; CHECK-LABEL: @rauw_if_possible( -; CHECK: call void @f4(i32 96) -define void @rauw_if_possible(i32 %value) nounwind { -entry: - %cmp = icmp eq i32 %value, 32 - br i1 %cmp, label %L0, label %L3 -L0: - call i32 @f2() - call i32 @f2() - %add = add i32 %value, 64 - switch i32 %add, label %L3 [ - i32 32, label %L1 - i32 96, label %L2 - ] - -L1: - call void @f3() - ret void -L2: - call void @f4(i32 %add) - ret void -L3: - call void @f3() - ret void -} - -; Make sure we can NOT do the RAUW for %add... -; -; CHECK-LABEL: @rauw_if_possible2( -; CHECK: call void @f4(i32 %add) -define void @rauw_if_possible2(i32 %value) nounwind { -entry: - %cmp = icmp eq i32 %value, 32 - %add = add i32 %value, 64 - br i1 %cmp, label %L0, label %L2 -L0: - call i32 @f2() - call i32 @f2() - switch i32 %add, label %L3 [ - i32 32, label %L1 - i32 96, label %L2 - ] - -L1: - call void @f3() - ret void -L2: - call void @f4(i32 %add) - ret void -L3: - call void @f3() - ret void -} - -; Make sure we can fold this branch ... We will not be able to thread it as -; L0 is too big to duplicate. -; We do not attempt to rewrite the indirectbr target here, but we still take -; its target after L0 into account and that enables us to fold. -; -; L2 is the unreachable block here. -; -; CHECK-LABEL: @test_br_folding_not_threading_indirect_branch( -; CHECK: L1: -; CHECK: call i32 @f2() -; CHECK: call void @f3() -; CHECK-NEXT: ret void -; CHECK-NOT: br -; CHECK: L3: -define void @test_br_folding_not_threading_indirect_branch(i1 %condx, i1 %cond) nounwind { -entry: - br i1 %condx, label %X0, label %X1 - -X0: - br i1 %cond, label %L0, label %L3 - -X1: - br i1 %cond, label %XX1, label %L3 - -XX1: - indirectbr i8* blockaddress(@test_br_folding_not_threading_indirect_branch, %L0), [label %L0] - -L0: - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - call i32 @f2() - br i1 %cond, label %L1, label %L2 - -L1: - call void @f3() - ret void - -L2: - call void @f3() - ret void - -L3: - call void @f3() - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/guards.ll b/llvm/test/Transforms/JumpThreading/guards.ll deleted file mode 100644 index c760283f9e5..00000000000 --- a/llvm/test/Transforms/JumpThreading/guards.ll +++ /dev/null @@ -1,383 +0,0 @@ -; RUN: opt < %s -jump-threading -dce -S | FileCheck %s - -declare void @llvm.experimental.guard(i1, ...) - -declare i32 @f1() -declare i32 @f2() - -define i32 @branch_implies_guard(i32 %a) { -; CHECK-LABEL: @branch_implies_guard( - %cond = icmp slt i32 %a, 10 - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: T1.split -; CHECK: %v1 = call i32 @f1() -; CHECK-NEXT: %retVal -; CHECK-NEXT: br label %Merge - %v1 = call i32 @f1() - br label %Merge - -F1: -; CHECK: F1.split -; CHECK: %v2 = call i32 @f2() -; CHECK-NEXT: %retVal -; CHECK-NEXT: %condGuard -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %condGuard -; CHECK-NEXT: br label %Merge - %v2 = call i32 @f2() - br label %Merge - -Merge: -; CHECK: Merge -; CHECK-NOT: call void(i1, ...) @llvm.experimental.guard( - %retPhi = phi i32 [ %v1, %T1 ], [ %v2, %F1 ] - %retVal = add i32 %retPhi, 10 - %condGuard = icmp slt i32 %a, 20 - call void(i1, ...) @llvm.experimental.guard(i1 %condGuard) [ "deopt"() ] - ret i32 %retVal -} - -define i32 @not_branch_implies_guard(i32 %a) { -; CHECK-LABEL: @not_branch_implies_guard( - %cond = icmp slt i32 %a, 20 - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: T1.split: -; CHECK-NEXT: %v1 = call i32 @f1() -; CHECK-NEXT: %retVal -; CHECK-NEXT: %condGuard -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %condGuard -; CHECK-NEXT: br label %Merge - %v1 = call i32 @f1() - br label %Merge - -F1: -; CHECK: F1.split: -; CHECK-NEXT: %v2 = call i32 @f2() -; CHECK-NEXT: %retVal -; CHECK-NEXT: br label %Merge - %v2 = call i32 @f2() - br label %Merge - -Merge: -; CHECK: Merge -; CHECK-NOT: call void(i1, ...) @llvm.experimental.guard( - %retPhi = phi i32 [ %v1, %T1 ], [ %v2, %F1 ] - %retVal = add i32 %retPhi, 10 - %condGuard = icmp sgt i32 %a, 10 - call void(i1, ...) @llvm.experimental.guard(i1 %condGuard) [ "deopt"() ] - ret i32 %retVal -} - -define i32 @branch_overlaps_guard(i32 %a) { -; CHECK-LABEL: @branch_overlaps_guard( - %cond = icmp slt i32 %a, 20 - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: T1: -; CHECK-NEXT: %v1 = call i32 @f1() -; CHECK-NEXT: br label %Merge - %v1 = call i32 @f1() - br label %Merge - -F1: -; CHECK: F1: -; CHECK-NEXT: %v2 = call i32 @f2() -; CHECK-NEXT: br label %Merge - %v2 = call i32 @f2() - br label %Merge - -Merge: -; CHECK: Merge -; CHECK: %condGuard = icmp slt i32 %a, 10 -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %condGuard) [ "deopt"() ] - %retPhi = phi i32 [ %v1, %T1 ], [ %v2, %F1 ] - %retVal = add i32 %retPhi, 10 - %condGuard = icmp slt i32 %a, 10 - call void(i1, ...) @llvm.experimental.guard(i1 %condGuard) [ "deopt"() ] - ret i32 %retVal -} - -define i32 @branch_doesnt_overlap_guard(i32 %a) { -; CHECK-LABEL: @branch_doesnt_overlap_guard( - %cond = icmp slt i32 %a, 10 - br i1 %cond, label %T1, label %F1 - -T1: -; CHECK: T1: -; CHECK-NEXT: %v1 = call i32 @f1() -; CHECK-NEXT: br label %Merge - %v1 = call i32 @f1() - br label %Merge - -F1: -; CHECK: F1: -; CHECK-NEXT: %v2 = call i32 @f2() -; CHECK-NEXT: br label %Merge - %v2 = call i32 @f2() - br label %Merge - -Merge: -; CHECK: Merge -; CHECK: %condGuard = icmp sgt i32 %a, 20 -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %condGuard) [ "deopt"() ] - %retPhi = phi i32 [ %v1, %T1 ], [ %v2, %F1 ] - %retVal = add i32 %retPhi, 10 - %condGuard = icmp sgt i32 %a, 20 - call void(i1, ...) @llvm.experimental.guard(i1 %condGuard) [ "deopt"() ] - ret i32 %retVal -} - -define i32 @not_a_diamond1(i32 %a, i1 %cond1) { -; CHECK-LABEL: @not_a_diamond1( - br i1 %cond1, label %Pred, label %Exit - -Pred: -; CHECK: Pred: -; CHECK-NEXT: switch i32 %a, label %Exit - switch i32 %a, label %Exit [ - i32 10, label %Merge - i32 20, label %Merge - ] - -Merge: -; CHECK: Merge: -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %cond1) [ "deopt"() ] -; CHECK-NEXT: br label %Exit - call void(i1, ...) @llvm.experimental.guard(i1 %cond1) [ "deopt"() ] - br label %Exit - -Exit: -; CHECK: Exit: -; CHECK-NEXT: ret i32 %a - ret i32 %a -} - -define void @not_a_diamond2(i32 %a, i1 %cond1) { -; CHECK-LABEL: @not_a_diamond2( - br label %Parent - -Merge: - call void(i1, ...) @llvm.experimental.guard(i1 %cond1)[ "deopt"() ] - ret void - -Pred: -; CHECK-NEXT: Pred: -; CHECK-NEXT: switch i32 %a, label %Exit - switch i32 %a, label %Exit [ - i32 10, label %Merge - i32 20, label %Merge - ] - -Parent: - br label %Pred - -Exit: -; CHECK: Merge: -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %cond1) [ "deopt"() ] -; CHECK-NEXT: ret void - ret void -} - -declare void @never_called(i1) - -; LVI uses guard to identify value of %c2 in branch as true, we cannot replace that -; guard with guard(true & c1). -define void @dont_fold_guard(i8* %addr, i32 %i, i32 %length) { -; CHECK-LABEL: dont_fold_guard -; CHECK: %wide.chk = and i1 %c1, %c2 -; CHECK-NEXT: experimental.guard(i1 %wide.chk) -; CHECK-NEXT: call void @never_called(i1 true) -; CHECK-NEXT: ret void - %c1 = icmp ult i32 %i, %length - %c2 = icmp eq i32 %i, 0 - %wide.chk = and i1 %c1, %c2 - call void(i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ] - br i1 %c2, label %BB1, label %BB2 - -BB1: - call void @never_called(i1 %c2) - ret void - -BB2: - ret void -} - -declare void @dummy(i1) nounwind argmemonly -; same as dont_fold_guard1 but there's a use immediately after guard and before -; branch. We can fold that use. -define void @dont_fold_guard2(i8* %addr, i32 %i, i32 %length) { -; CHECK-LABEL: dont_fold_guard2 -; CHECK: %wide.chk = and i1 %c1, %c2 -; CHECK-NEXT: experimental.guard(i1 %wide.chk) -; CHECK-NEXT: dummy(i1 true) -; CHECK-NEXT: call void @never_called(i1 true) -; CHECK-NEXT: ret void - %c1 = icmp ult i32 %i, %length - %c2 = icmp eq i32 %i, 0 - %wide.chk = and i1 %c1, %c2 - call void(i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ] - call void @dummy(i1 %c2) - br i1 %c2, label %BB1, label %BB2 - -BB1: - call void @never_called(i1 %c2) - ret void - -BB2: - ret void -} - -; same as dont_fold_guard1 but condition %cmp is not an instruction. -; We cannot fold the guard under any circumstance. -; FIXME: We can merge unreachableBB2 into not_zero. -define void @dont_fold_guard3(i8* %addr, i1 %cmp, i32 %i, i32 %length) { -; CHECK-LABEL: dont_fold_guard3 -; CHECK: guard(i1 %cmp) - call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ] - br i1 %cmp, label %BB1, label %BB2 - -BB1: - call void @never_called(i1 %cmp) - ret void - -BB2: - ret void -} - -declare void @f(i1) -; Same as dont_fold_guard1 but use switch instead of branch. -; triggers source code `ProcessThreadableEdges`. -define void @dont_fold_guard4(i1 %cmp1, i32 %i) nounwind { -; CHECK-LABEL: dont_fold_guard4 -; CHECK-LABEL: L2: -; CHECK-NEXT: %cmp = icmp eq i32 %i, 0 -; CHECK-NEXT: guard(i1 %cmp) -; CHECK-NEXT: dummy(i1 true) -; CHECK-NEXT: @f(i1 true) -; CHECK-NEXT: ret void -entry: - br i1 %cmp1, label %L0, label %L3 -L0: - %cmp = icmp eq i32 %i, 0 - call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ] - call void @dummy(i1 %cmp) - switch i1 %cmp, label %L3 [ - i1 false, label %L1 - i1 true, label %L2 - ] - -L1: - ret void -L2: - call void @f(i1 %cmp) - ret void -L3: - ret void -} - -; Make sure that we don't PRE a non-speculable load across a guard. -define void @unsafe_pre_across_guard(i8* %p, i1 %load.is.valid) { - -; CHECK-LABEL: @unsafe_pre_across_guard( -; CHECK-NOT: loaded.pr -; CHECK: entry: -; CHECK-NEXT: br label %loop -; CHECK: loop: -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %load.is.valid) [ "deopt"() ] -; CHECK-NEXT: %loaded = load i8, i8* %p -; CHECK-NEXT: %continue = icmp eq i8 %loaded, 0 -; CHECK-NEXT: br i1 %continue, label %exit, label %loop -entry: - br label %loop - -loop: ; preds = %loop, %entry - call void (i1, ...) @llvm.experimental.guard(i1 %load.is.valid) [ "deopt"() ] - %loaded = load i8, i8* %p - %continue = icmp eq i8 %loaded, 0 - br i1 %continue, label %exit, label %loop - -exit: ; preds = %loop - ret void -} - -; Make sure that we can safely PRE a speculable load across a guard. -define void @safe_pre_across_guard(i8* noalias nocapture readonly dereferenceable(8) %p, i1 %load.is.valid) { - -; CHECK-LABEL: @safe_pre_across_guard( -; CHECK: entry: -; CHECK-NEXT: %loaded.pr = load i8, i8* %p -; CHECK-NEXT: br label %loop -; CHECK: loop: -; CHECK-NEXT: %loaded = phi i8 [ %loaded, %loop ], [ %loaded.pr, %entry ] -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %load.is.valid) [ "deopt"() ] -; CHECK-NEXT: %continue = icmp eq i8 %loaded, 0 -; CHECK-NEXT: br i1 %continue, label %exit, label %loop - -entry: - br label %loop - -loop: ; preds = %loop, %entry - call void (i1, ...) @llvm.experimental.guard(i1 %load.is.valid) [ "deopt"() ] - %loaded = load i8, i8* %p - %continue = icmp eq i8 %loaded, 0 - br i1 %continue, label %exit, label %loop - -exit: ; preds = %loop - ret void -} - -; Make sure that we don't PRE a non-speculable load across a call which may -; alias with the load. -define void @unsafe_pre_across_call(i8* %p) { - -; CHECK-LABEL: @unsafe_pre_across_call( -; CHECK-NOT: loaded.pr -; CHECK: entry: -; CHECK-NEXT: br label %loop -; CHECK: loop: -; CHECK-NEXT: call i32 @f1() -; CHECK-NEXT: %loaded = load i8, i8* %p -; CHECK-NEXT: %continue = icmp eq i8 %loaded, 0 -; CHECK-NEXT: br i1 %continue, label %exit, label %loop -entry: - br label %loop - -loop: ; preds = %loop, %entry - call i32 @f1() - %loaded = load i8, i8* %p - %continue = icmp eq i8 %loaded, 0 - br i1 %continue, label %exit, label %loop - -exit: ; preds = %loop - ret void -} - -; Make sure that we can safely PRE a speculable load across a call. -define void @safe_pre_across_call(i8* noalias nocapture readonly dereferenceable(8) %p) { - -; CHECK-LABEL: @safe_pre_across_call( -; CHECK: entry: -; CHECK-NEXT: %loaded.pr = load i8, i8* %p -; CHECK-NEXT: br label %loop -; CHECK: loop: -; CHECK-NEXT: %loaded = phi i8 [ %loaded, %loop ], [ %loaded.pr, %entry ] -; CHECK-NEXT: call i32 @f1() -; CHECK-NEXT: %continue = icmp eq i8 %loaded, 0 -; CHECK-NEXT: br i1 %continue, label %exit, label %loop - -entry: - br label %loop - -loop: ; preds = %loop, %entry - call i32 @f1() - %loaded = load i8, i8* %p - %continue = icmp eq i8 %loaded, 0 - br i1 %continue, label %exit, label %loop - -exit: ; preds = %loop - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/header-succ.ll b/llvm/test/Transforms/JumpThreading/header-succ.ll deleted file mode 100644 index 859d44cff29..00000000000 --- a/llvm/test/Transforms/JumpThreading/header-succ.ll +++ /dev/null @@ -1,99 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - -; Check that the heuristic for avoiding accidental introduction of irreducible -; loops doesn't also prevent us from threading simple constructs where this -; isn't a problem. - -declare void @opaque_body() - -define void @jump_threading_loopheader() { -; CHECK-LABEL: @jump_threading_loopheader -top: - br label %entry - -entry: - %ind = phi i32 [0, %top], [%nextind, %latch] - %nextind = add i32 %ind, 1 - %cmp = icmp ule i32 %ind, 10 -; CHECK: br i1 %cmp, label %latch, label %exit - br i1 %cmp, label %body, label %latch - -body: - call void @opaque_body() -; CHECK: br label %entry - br label %latch - -latch: - %cond = phi i2 [1, %entry], [2, %body] - switch i2 %cond, label %unreach [ - i2 2, label %entry - i2 1, label %exit - ] - -unreach: - unreachable - -exit: - ret void -} - -; We also need to check the opposite order of the branches, in the switch -; instruction because jump-threading relies on that to decide which edge to -; try to thread first. -define void @jump_threading_loopheader2() { -; CHECK-LABEL: @jump_threading_loopheader2 -top: - br label %entry - -entry: - %ind = phi i32 [0, %top], [%nextind, %latch] - %nextind = add i32 %ind, 1 - %cmp = icmp ule i32 %ind, 10 -; CHECK: br i1 %cmp, label %exit, label %latch - br i1 %cmp, label %body, label %latch - -body: - call void @opaque_body() -; CHECK: br label %entry - br label %latch - -latch: - %cond = phi i2 [1, %entry], [2, %body] - switch i2 %cond, label %unreach [ - i2 1, label %entry - i2 2, label %exit - ] - -unreach: - unreachable - -exit: - ret void -} - -; Check if we can handle undef branch condition. -define void @jump_threading_loopheader3() { -; CHECK-LABEL: @jump_threading_loopheader3 -top: - br label %entry - -entry: - %ind = phi i32 [0, %top], [%nextind, %latch] - %nextind = add i32 %ind, 1 - %cmp = icmp ule i32 %ind, 10 -; CHECK: br i1 %cmp, label %latch, label %exit - br i1 %cmp, label %body, label %latch - -body: - call void @opaque_body() -; CHECK: br label %entry - br label %latch - -latch: - %phi = phi i32 [undef, %entry], [0, %body] - %cmp1 = icmp eq i32 %phi, 0 - br i1 %cmp1, label %entry, label %exit - -exit: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/implied-cond.ll b/llvm/test/Transforms/JumpThreading/implied-cond.ll deleted file mode 100644 index 6da05791456..00000000000 --- a/llvm/test/Transforms/JumpThreading/implied-cond.ll +++ /dev/null @@ -1,177 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s - -declare void @side_effect(i32) - -define void @test0(i32 %i, i32 %len) { -; CHECK-LABEL: @test0( - entry: - call void @side_effect(i32 0) - %i.inc = add nuw i32 %i, 1 - %c0 = icmp ult i32 %i.inc, %len - br i1 %c0, label %left, label %right - - left: -; CHECK: entry: -; CHECK: br i1 %c0, label %left0, label %right - -; CHECK: left0: -; CHECK: call void @side_effect -; CHECK-NOT: br i1 %c1 -; CHECK: call void @side_effect - call void @side_effect(i32 0) - %c1 = icmp ult i32 %i, %len - br i1 %c1, label %left0, label %right - - left0: - call void @side_effect(i32 0) - ret void - - right: - %t = phi i32 [ 1, %left ], [ 2, %entry ] - call void @side_effect(i32 %t) - ret void -} - -define void @test1(i32 %i, i32 %len) { -; CHECK-LABEL: @test1( - entry: - call void @side_effect(i32 0) - %i.inc = add nsw i32 %i, 1 - %c0 = icmp slt i32 %i.inc, %len - br i1 %c0, label %left, label %right - - left: -; CHECK: entry: -; CHECK: br i1 %c0, label %left0, label %right - -; CHECK: left0: -; CHECK: call void @side_effect -; CHECK-NOT: br i1 %c1 -; CHECK: call void @side_effect - call void @side_effect(i32 0) - %c1 = icmp slt i32 %i, %len - br i1 %c1, label %left0, label %right - - left0: - call void @side_effect(i32 0) - ret void - - right: - %t = phi i32 [ 1, %left ], [ 2, %entry ] - call void @side_effect(i32 %t) - ret void -} - -define void @test2(i32 %i, i32 %len, i1* %c.ptr) { -; CHECK-LABEL: @test2( - -; CHECK: entry: -; CHECK: br i1 %c0, label %cont, label %right -; CHECK: cont: -; CHECK: br i1 %c, label %left0, label %right -; CHECK: left0: -; CHECK: call void @side_effect(i32 0) -; CHECK: call void @side_effect(i32 0) - entry: - call void @side_effect(i32 0) - %i.inc = add nsw i32 %i, 1 - %c0 = icmp slt i32 %i.inc, %len - br i1 %c0, label %cont, label %right - - cont: - %c = load i1, i1* %c.ptr - br i1 %c, label %left, label %right - - left: - call void @side_effect(i32 0) - %c1 = icmp slt i32 %i, %len - br i1 %c1, label %left0, label %right - - left0: - call void @side_effect(i32 0) - ret void - - right: - %t = phi i32 [ 1, %left ], [ 2, %entry ], [ 3, %cont ] - call void @side_effect(i32 %t) - ret void -} - -; A s<= B implies A s> B is false. -; CHECK-LABEL: @test3( -; CHECK: entry: -; CHECK: br i1 %cmp, label %if.end, label %if.end3 -; CHECK-NOT: br i1 %cmp1, label %if.then2, label %if.end -; CHECK-NOT: call void @side_effect(i32 0) -; CHECK: br label %if.end3 -; CHECK: ret void - -define void @test3(i32 %a, i32 %b) { -entry: - %cmp = icmp sle i32 %a, %b - br i1 %cmp, label %if.then, label %if.end3 - -if.then: - %cmp1 = icmp sgt i32 %a, %b - br i1 %cmp1, label %if.then2, label %if.end - -if.then2: - call void @side_effect(i32 0) - br label %if.end - -if.end: - br label %if.end3 - -if.end3: - ret void -} - -declare void @is(i1) - -; If A >=s B is false then A <=s B is implied true. -; CHECK-LABEL: @test_sge_sle -; CHECK: call void @is(i1 true) -; CHECK-NOT: call void @is(i1 false) -define void @test_sge_sle(i32 %a, i32 %b) { - %cmp1 = icmp sge i32 %a, %b - br i1 %cmp1, label %untaken, label %taken - -taken: - %cmp2 = icmp sle i32 %a, %b - br i1 %cmp2, label %istrue, label %isfalse - -istrue: - call void @is(i1 true) - ret void - -isfalse: - call void @is(i1 false) - ret void - -untaken: - ret void -} - -; If A <=s B is false then A <=s B is implied false. -; CHECK-LABEL: @test_sle_sle -; CHECK-NOT: call void @is(i1 true) -; CHECK: call void @is(i1 false) -define void @test_sle_sle(i32 %a, i32 %b) { - %cmp1 = icmp sle i32 %a, %b - br i1 %cmp1, label %untaken, label %taken - -taken: - %cmp2 = icmp sle i32 %a, %b - br i1 %cmp2, label %istrue, label %isfalse - -istrue: - call void @is(i1 true) - ret void - -isfalse: - call void @is(i1 false) - ret void - -untaken: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/indirectbr.ll b/llvm/test/Transforms/JumpThreading/indirectbr.ll deleted file mode 100644 index 197ca30f58a..00000000000 --- a/llvm/test/Transforms/JumpThreading/indirectbr.ll +++ /dev/null @@ -1,94 +0,0 @@ -; RUN: opt -S < %s -jump-threading | FileCheck %s - -; Keep block addresses alive. -@addresses = constant [4 x i8*] [ - i8* blockaddress(@test1, %L1), i8* blockaddress(@test1, %L2), - i8* blockaddress(@test2, %L1), i8* blockaddress(@test2, %L2) -] - -declare void @bar() -declare void @baz() - - - -; Check basic jump threading for indirectbr instructions. - -; CHECK: void @test1 -; CHECK: br i1 %tobool, label %L1, label %indirectgoto -; CHECK-NOT: if.else: -; CHECK: L1: -; CHECK: indirectbr i8* %address, [label %L1, label %L2] -define void @test1(i32 %i, i8* %address) nounwind { -entry: - %rem = srem i32 %i, 2 - %tobool = icmp ne i32 %rem, 0 - br i1 %tobool, label %indirectgoto, label %if.else - -if.else: ; preds = %entry - br label %indirectgoto - -L1: ; preds = %indirectgoto - call void @bar() - ret void - -L2: ; preds = %indirectgoto - call void @baz() - ret void - -indirectgoto: ; preds = %if.else, %entry - %indirect.goto.dest = phi i8* [ %address, %if.else ], [ blockaddress(@test1, %L1), %entry ] - indirectbr i8* %indirect.goto.dest, [label %L1, label %L2] -} - - -; Check constant folding of indirectbr - -; CHECK: void @test2 -; CHECK: entry: -; CHECK-NEXT: br label %L1 -; CHECK: L1: -; CHECK-NEXT: call void @bar -; CHECK-NEXT: ret void -define void @test2() nounwind { -entry: - indirectbr i8* blockaddress(@test2, %L1), [label %L1, label %L2] - -L1: ; preds = %indirectgoto - call void @bar() - ret void - -L2: ; preds = %indirectgoto - call void @baz() - ret void -} - - -; PR4151 -; Don't merge address-taken blocks. -@.str = private unnamed_addr constant [4 x i8] c"%p\0A\00" - -; CHECK-LABEL: @test3( -; CHECK: __here: -; CHECK: blockaddress(@test3, %__here) -; CHECK: __here1: -; CHECK: blockaddress(@test3, %__here1) -; CHECK: __here3: -; CHECK: blockaddress(@test3, %__here3) -define void @test3() nounwind ssp noredzone { -entry: - br label %__here - -__here: ; preds = %entry - %call = call i32 (...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 ptrtoint (i8* blockaddress(@test3, %__here) to i64)) nounwind noredzone - br label %__here1 - -__here1: ; preds = %__here - %call2 = call i32 (...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 ptrtoint (i8* blockaddress(@test3, %__here1) to i64)) nounwind noredzone - br label %__here3 - -__here3: ; preds = %__here1 - %call4 = call i32 (...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 ptrtoint (i8* blockaddress(@test3, %__here3) to i64)) nounwind noredzone - ret void -} - -declare i32 @printf(...) noredzone diff --git a/llvm/test/Transforms/JumpThreading/induction.ll b/llvm/test/Transforms/JumpThreading/induction.ll deleted file mode 100644 index 714c28d1443..00000000000 --- a/llvm/test/Transforms/JumpThreading/induction.ll +++ /dev/null @@ -1,25 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - -define i8 @test(i32 %a, i32 %length) { -; CHECK-LABEL: @test -entry: -; CHECK: br label %backedge - br label %loop - -loop: -; CHECK-LABEL: backedge: -; CHECK: phi i32 -; CHECK: br i1 %cont, label %backedge, label %exit - %iv = phi i32 [0, %entry], [%iv.next, %backedge] - ;; We can use an inductive argument to prove %iv is always positive - %cnd = icmp sge i32 %iv, 0 - br i1 %cnd, label %backedge, label %exit - -backedge: - %iv.next = add nsw i32 %iv, 1 - %cont = icmp slt i32 %iv.next, 400 - br i1 %cont, label %loop, label %exit -exit: - ret i8 0 -} - diff --git a/llvm/test/Transforms/JumpThreading/landing-pad.ll b/llvm/test/Transforms/JumpThreading/landing-pad.ll deleted file mode 100644 index 5dcc5aa17e6..00000000000 --- a/llvm/test/Transforms/JumpThreading/landing-pad.ll +++ /dev/null @@ -1,203 +0,0 @@ -; RUN: opt < %s -disable-output -jump-threading - -%class.E = type { i32 (...)**, %class.C } -%class.C = type { %class.A } -%class.A = type { i32 } -%class.D = type { %class.F } -%class.F = type { %class.E } -%class.B = type { %class.D* } - -@_ZTV1D = unnamed_addr constant [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1D to i8*), i8* bitcast (void (%class.D*)* @_ZN1D7doApplyEv to i8*)] -@_ZTI1D = external unnamed_addr constant { i8*, i8*, i8* } - -define void @_ZN15EditCommandImpl5applyEv(%class.E* %this) uwtable align 2 { -entry: - %0 = bitcast %class.E* %this to void (%class.E*)*** - %vtable = load void (%class.E*)**, void (%class.E*)*** %0, align 8 - %1 = load void (%class.E*)*, void (%class.E*)** %vtable, align 8 - call void %1(%class.E* %this) - ret void -} - -define void @_ZN1DC1Ev(%class.D* nocapture %this) unnamed_addr uwtable align 2 { -entry: - call void @_ZN24CompositeEditCommandImplC2Ev() - %0 = getelementptr inbounds %class.D, %class.D* %this, i64 0, i32 0, i32 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTV1D, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 - ret void -} - -define void @_ZN1DC2Ev(%class.D* nocapture %this) unnamed_addr uwtable align 2 { -entry: - call void @_ZN24CompositeEditCommandImplC2Ev() - %0 = getelementptr inbounds %class.D, %class.D* %this, i64 0, i32 0, i32 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTV1D, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 - ret void -} - -declare void @_ZN24CompositeEditCommandImplC2Ev() #1 - -define void @_ZN1D7doApplyEv(%class.D* nocapture %this) unnamed_addr nounwind readnone uwtable align 2 { -entry: - ret void -} - -define void @_Z3fn1v() uwtable personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { -entry: - %call = call noalias i8* @_Znwm() #8 - invoke void @_ZN24CompositeEditCommandImplC2Ev() - to label %_ZN1DC1Ev.exit unwind label %lpad - -_ZN1DC1Ev.exit: ; preds = %entry - %0 = bitcast i8* %call to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTV1D, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 - %_ref.i.i.i = getelementptr inbounds i8, i8* %call, i64 8 - %1 = bitcast i8* %_ref.i.i.i to i32* - %2 = load i32, i32* %1, align 4 - %inc.i.i.i = add nsw i32 %2, 1 - store i32 %inc.i.i.i, i32* %1, align 4 - %3 = bitcast i8* %call to %class.D* - invoke void @_ZN1D7doApplyEv(%class.D* %3) - to label %_ZN15EditCommandImpl5applyEv.exit unwind label %lpad1 - -_ZN15EditCommandImpl5applyEv.exit: ; preds = %_ZN1DC1Ev.exit - invoke void @_ZN1D16deleteKeyPressedEv() - to label %invoke.cont7 unwind label %lpad1 - -invoke.cont7: ; preds = %_ZN15EditCommandImpl5applyEv.exit - ret void - -lpad: ; preds = %entry - %4 = landingpad { i8*, i32 } - cleanup - call void @_ZdlPv() #9 - unreachable - -lpad1: ; preds = %_ZN1DC1Ev.exit, %_ZN15EditCommandImpl5applyEv.exit - %5 = landingpad { i8*, i32 } - cleanup - %6 = load i32, i32* %1, align 4 - %tobool.i.i.i = icmp eq i32 %6, 0 - br i1 %tobool.i.i.i, label %_ZN1BI1DED1Ev.exit, label %if.then.i.i.i - -if.then.i.i.i: ; preds = %lpad1 - br i1 undef, label %_ZN1BI1DED1Ev.exit, label %delete.notnull.i.i.i - -delete.notnull.i.i.i: ; preds = %if.then.i.i.i - call void @_ZdlPv() #9 - unreachable - -_ZN1BI1DED1Ev.exit: ; preds = %lpad1, %if.then.i.i.i - resume { i8*, i32 } undef - -terminate.lpad: ; No predecessors! - %7 = landingpad { i8*, i32 } - catch i8* null - unreachable -} - -define void @_ZN1BI1DEC1EPS0_(%class.B* nocapture %this, %class.D* %p1) unnamed_addr uwtable align 2 { -entry: - %m_ptr.i = getelementptr inbounds %class.B, %class.B* %this, i64 0, i32 0 - store %class.D* %p1, %class.D** %m_ptr.i, align 8 - %_ref.i.i = getelementptr inbounds %class.D, %class.D* %p1, i64 0, i32 0, i32 0, i32 1, i32 0, i32 0 - %0 = load i32, i32* %_ref.i.i, align 4 - %inc.i.i = add nsw i32 %0, 1 - store i32 %inc.i.i, i32* %_ref.i.i, align 4 - ret void -} - -declare noalias i8* @_Znwm() - -declare i32 @__gxx_personality_v0(...) - -declare void @_ZdlPv() - -define %class.D* @_ZN1BI1DEptEv(%class.B* nocapture readonly %this) nounwind readonly uwtable align 2 { -entry: - %m_ptr = getelementptr inbounds %class.B, %class.B* %this, i64 0, i32 0 - %0 = load %class.D*, %class.D** %m_ptr, align 8 - ret %class.D* %0 -} - -declare void @_ZN1D16deleteKeyPressedEv() - -define void @_ZN1BI1DED1Ev(%class.B* nocapture readonly %this) unnamed_addr uwtable align 2 { -entry: - %m_ptr.i = getelementptr inbounds %class.B, %class.B* %this, i64 0, i32 0 - %0 = load %class.D*, %class.D** %m_ptr.i, align 8 - %_ref.i.i = getelementptr inbounds %class.D, %class.D* %0, i64 0, i32 0, i32 0, i32 1, i32 0, i32 0 - %1 = load i32, i32* %_ref.i.i, align 4 - %tobool.i.i = icmp eq i32 %1, 0 - br i1 %tobool.i.i, label %_ZN1BI1DED2Ev.exit, label %if.then.i.i - -if.then.i.i: ; preds = %entry - br i1 undef, label %_ZN1BI1DED2Ev.exit, label %delete.notnull.i.i - -delete.notnull.i.i: ; preds = %if.then.i.i - call void @_ZdlPv() #9 - unreachable - -_ZN1BI1DED2Ev.exit: ; preds = %entry, %if.then.i.i - ret void -} - -declare hidden void @__clang_call_terminate() - -define void @_ZN1BI1DED2Ev(%class.B* nocapture readonly %this) unnamed_addr uwtable align 2 { -entry: - %m_ptr = getelementptr inbounds %class.B, %class.B* %this, i64 0, i32 0 - %0 = load %class.D*, %class.D** %m_ptr, align 8 - %_ref.i = getelementptr inbounds %class.D, %class.D* %0, i64 0, i32 0, i32 0, i32 1, i32 0, i32 0 - %1 = load i32, i32* %_ref.i, align 4 - %tobool.i = icmp eq i32 %1, 0 - br i1 %tobool.i, label %_ZN1AI1CE5derefEv.exit, label %if.then.i - -if.then.i: ; preds = %entry - br i1 undef, label %_ZN1AI1CE5derefEv.exit, label %delete.notnull.i - -delete.notnull.i: ; preds = %if.then.i - call void @_ZdlPv() #9 - unreachable - -_ZN1AI1CE5derefEv.exit: ; preds = %entry, %if.then.i - ret void -} - -define void @_ZN1AI1CE5derefEv(%class.A* nocapture readonly %this) nounwind uwtable align 2 { -entry: - %_ref = getelementptr inbounds %class.A, %class.A* %this, i64 0, i32 0 - %0 = load i32, i32* %_ref, align 4 - %tobool = icmp eq i32 %0, 0 - br i1 %tobool, label %if.end, label %if.then - -if.then: ; preds = %entry - br i1 undef, label %if.end, label %delete.notnull - -delete.notnull: ; preds = %if.then - call void @_ZdlPv() #9 - unreachable - -if.end: ; preds = %entry, %if.then - ret void -} - -define void @_ZN1BI1DEC2EPS0_(%class.B* nocapture %this, %class.D* %p1) unnamed_addr uwtable align 2 { -entry: - %m_ptr = getelementptr inbounds %class.B, %class.B* %this, i64 0, i32 0 - store %class.D* %p1, %class.D** %m_ptr, align 8 - %_ref.i = getelementptr inbounds %class.D, %class.D* %p1, i64 0, i32 0, i32 0, i32 1, i32 0, i32 0 - %0 = load i32, i32* %_ref.i, align 4 - %inc.i = add nsw i32 %0, 1 - store i32 %inc.i, i32* %_ref.i, align 4 - ret void -} - -define void @_ZN1AI1CE3refEv(%class.A* nocapture %this) nounwind uwtable align 2 { -entry: - %_ref = getelementptr inbounds %class.A, %class.A* %this, i64 0, i32 0 - %0 = load i32, i32* %_ref, align 4 - %inc = add nsw i32 %0, 1 - store i32 %inc, i32* %_ref, align 4 - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/lvi-load.ll b/llvm/test/Transforms/JumpThreading/lvi-load.ll deleted file mode 100644 index a36e263bf92..00000000000 --- a/llvm/test/Transforms/JumpThreading/lvi-load.ll +++ /dev/null @@ -1,49 +0,0 @@ -; RUN: opt -S -jump-threading -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", %"struct.llvm::Value"* %V, i64 0, i32 1 ; <i8*> [#uses=1] - %1 = load i8, 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], [5 x i8]* @_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 202, i8* getelementptr inbounds ([59 x i8], [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"*) diff --git a/llvm/test/Transforms/JumpThreading/lvi-tristate.ll b/llvm/test/Transforms/JumpThreading/lvi-tristate.ll deleted file mode 100644 index 0aa87383347..00000000000 --- a/llvm/test/Transforms/JumpThreading/lvi-tristate.ll +++ /dev/null @@ -1,50 +0,0 @@ -; RUN: opt -jump-threading -simplifycfg -S < %s | FileCheck %s -; CHECK-NOT: bb6: -; CHECK-NOT: bb7: -; CHECK-NOT: bb8: -; CHECK-NOT: bb11: -; CHECK-NOT: bb12: -; CHECK: bb: -; CHECK: bb2: -; CHECK: bb4: -; CHECK: bb10: -; CHECK: bb13: -declare void @ham() - -define void @hoge() { -bb: - %tmp = and i32 undef, 1073741823 - %tmp1 = icmp eq i32 %tmp, 2 - br i1 %tmp1, label %bb12, label %bb2 - -bb2: - %tmp3 = icmp eq i32 %tmp, 3 - br i1 %tmp3, label %bb13, label %bb4 - -bb4: - %tmp5 = icmp eq i32 %tmp, 5 - br i1 %tmp5, label %bb6, label %bb7 - -bb6: - tail call void @ham() - br label %bb7 - -bb7: - br i1 %tmp3, label %bb13, label %bb8 - -bb8: - %tmp9 = icmp eq i32 %tmp, 4 - br i1 %tmp9, label %bb13, label %bb10 - -bb10: - br i1 %tmp9, label %bb11, label %bb13 - -bb11: - br label %bb13 - -bb12: - br label %bb2 - -bb13: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/no-irreducible-loops.ll b/llvm/test/Transforms/JumpThreading/no-irreducible-loops.ll deleted file mode 100644 index c6e9faa1711..00000000000 --- a/llvm/test/Transforms/JumpThreading/no-irreducible-loops.ll +++ /dev/null @@ -1,38 +0,0 @@ -; RUN: opt < %s -jump-threading -loop-rotate -instcombine -indvars -loop-unroll -simplifycfg -S -verify-dom-info -verify-loop-info > %t -; RUN: grep "store volatile" %t | count 3 -; RUN: not grep "br label" %t - -; Jump threading should not prevent this loop from being unrolled. - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin9.6" -@v1 = external global i32 ; <i32*> [#uses=2] - -define i32 @unroll() nounwind { -entry: - br label %bb4 - -bb: ; preds = %bb4 - %0 = icmp eq i32 %i.0, 0 ; <i1> [#uses=1] - br i1 %0, label %bb1, label %bb2 - -bb1: ; preds = %bb - store volatile i32 1000, i32* @v1, align 4 - br label %bb3 - -bb2: ; preds = %bb - store volatile i32 1001, i32* @v1, align 4 - br label %bb3 - -bb3: ; preds = %bb2, %bb1 - %1 = add i32 %i.0, 1 ; <i32> [#uses=1] - br label %bb4 - -bb4: ; preds = %bb3, %entry - %i.0 = phi i32 [ 0, %entry ], [ %1, %bb3 ] ; <i32> [#uses=3] - %2 = icmp sgt i32 %i.0, 2 ; <i1> [#uses=1] - br i1 %2, label %bb5, label %bb - -bb5: ; preds = %bb4 - ret i32 0 -} diff --git a/llvm/test/Transforms/JumpThreading/or-undef.ll b/llvm/test/Transforms/JumpThreading/or-undef.ll deleted file mode 100644 index b55bdddc196..00000000000 --- a/llvm/test/Transforms/JumpThreading/or-undef.ll +++ /dev/null @@ -1,69 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s -; rdar://7620633 - -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-darwin11.0" - -define void @test1(i8* %args, i32 %from_tty) nounwind optsize ssp { -entry: - %tmp = call i8* @f3(void (i8*)* null, i8* null) nounwind ; <i8*> [#uses=1] - %tmp1 = icmp eq i8* %args, null ; <i1> [#uses=1] - br i1 %tmp1, label %bb2, label %bb - -; CHECK: entry: -; CHECK-NEXT: %tmp = call i8* @f3 -; CHECK-NEXT: %tmp1 = icmp eq i8* %args, null -; CHECK-NEXT: br i1 %tmp1, label %bb7, label %bb - -bb: ; preds = %entry - %tmp2 = call noalias i8** @buildargv(i8* %args) nounwind ; <i8**> [#uses=4] - %tmp3 = icmp eq i8** %tmp2, null ; <i1> [#uses=1] - br i1 %tmp3, label %bb2, label %bb1 - -bb1: ; preds = %bb - call void @f2(i8** %tmp2) nounwind - br label %bb2 - -bb2: ; preds = %bb1, %bb, %entry - %argv.0 = phi i8** [ %tmp2, %bb1 ], [ %tmp2, %bb ], [ undef, %entry ] ; <i8**> [#uses=4] - %tmp5 = icmp eq i8* %args, null ; <i1> [#uses=1] - %tmp6 = icmp eq i8** %argv.0, null ; <i1> [#uses=1] - %tmp7 = or i1 %tmp5, %tmp6 ; <i1> [#uses=1] - br i1 %tmp7, label %bb7, label %bb5 - -bb5: ; preds = %bb2 - %tmp8 = load i8*, i8** %argv.0, align 8 ; <i8*> [#uses=1] - %tmp9 = icmp eq i8* %tmp8, null ; <i1> [#uses=1] - br i1 %tmp9, label %bb7, label %bb6 - -bb6: ; preds = %bb5 - %tmp10 = load i8*, i8** %argv.0, align 8 ; <i8*> [#uses=1] - %tmp11 = load i8, i8* %tmp10, align 1 ; <i8> [#uses=1] - %tmp12 = icmp eq i8 %tmp11, 0 ; <i1> [#uses=1] - br i1 %tmp12, label %bb7, label %bb8 - -bb7: ; preds = %bb6, %bb5, %bb2 - call void @f1() nounwind optsize ssp - br label %bb9 - -bb8: ; preds = %bb6 - %tmp13 = load i8*, i8** %argv.0, align 8 ; <i8*> [#uses=1] - %tmp14 = call i64 @f5(i8* %tmp13) nounwind ; <i64> [#uses=0] - br label %bb9 - -bb9: ; preds = %bb8, %bb7 - call void @f4(i8* %tmp) nounwind - ret void -} - -declare noalias i8** @buildargv(i8*) - -declare void @f2(i8**) - -declare void @f4(i8*) - -declare i8* @f3(void (i8*)*, i8*) - -declare void @f1() - -declare i64 @f5(i8*) diff --git a/llvm/test/Transforms/JumpThreading/phi-eq.ll b/llvm/test/Transforms/JumpThreading/phi-eq.ll deleted file mode 100644 index 75e8cc81fed..00000000000 --- a/llvm/test/Transforms/JumpThreading/phi-eq.ll +++ /dev/null @@ -1,209 +0,0 @@ -; RUN: opt < %s -jump-threading -S | FileCheck %s -; Test whether two consecutive switches with identical structures assign the -; proper value to the proper variable. This is really testing -; Instruction::isIdenticalToWhenDefined, as previously that function was -; returning true if the value part of the operands of two phis were identical, -; even if the incoming blocks were not. -; NB: this function should be pruned down more. - -%struct._GList = type { i8*, %struct._GList*, %struct._GList* } -%struct.filter_def = type { i8*, i8* } - -@capture_filters = external hidden global %struct._GList*, align 8 -@display_filters = external hidden global %struct._GList*, align 8 -@.str2 = external hidden unnamed_addr constant [10 x i8], align 1 -@__PRETTY_FUNCTION__.copy_filter_list = external hidden unnamed_addr constant [62 x i8], align 1 -@.str12 = external hidden unnamed_addr constant [22 x i8], align 1 -@.str13 = external hidden unnamed_addr constant [31 x i8], align 1 -@capture_edited_filters = external hidden global %struct._GList*, align 8 -@display_edited_filters = external hidden global %struct._GList*, align 8 -@__PRETTY_FUNCTION__.get_filter_list = external hidden unnamed_addr constant [44 x i8], align 1 - -declare void @g_assertion_message(i8*, i8*, i32, i8*, i8*) noreturn - -declare void @g_free(i8*) - -declare %struct._GList* @g_list_first(%struct._GList*) - -declare noalias i8* @g_malloc(i64) - -define void @copy_filter_list(i32 %dest_type, i32 %src_type) nounwind uwtable ssp { -entry: - br label %do.body - -do.body: ; preds = %entry - %cmp = icmp ne i32 %dest_type, %src_type - br i1 %cmp, label %if.then, label %if.else - -if.then: ; preds = %do.body - br label %if.end - -if.else: ; preds = %do.body - call void @g_assertion_message_expr(i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str2, i32 0, i32 0), i32 581, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @__PRETTY_FUNCTION__.copy_filter_list, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str12, i32 0, i32 0)) noreturn - unreachable - -if.end: ; preds = %if.then - br label %do.end - -do.end: ; preds = %if.end - switch i32 %dest_type, label %sw.default.i [ - i32 0, label %sw.bb.i - i32 1, label %sw.bb1.i - i32 2, label %sw.bb2.i - i32 3, label %sw.bb3.i - ] - -sw.bb.i: ; preds = %do.end - br label %get_filter_list.exit - -sw.bb1.i: ; preds = %do.end - br label %get_filter_list.exit - -sw.bb2.i: ; preds = %do.end - br label %get_filter_list.exit - -sw.bb3.i: ; preds = %do.end - br label %get_filter_list.exit - -sw.default.i: ; preds = %do.end - call void @g_assertion_message(i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str2, i32 0, i32 0), i32 408, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @__PRETTY_FUNCTION__.get_filter_list, i32 0, i32 0), i8* null) noreturn nounwind - unreachable - -get_filter_list.exit: ; preds = %sw.bb3.i, %sw.bb2.i, %sw.bb1.i, %sw.bb.i - %0 = phi %struct._GList** [ @display_edited_filters, %sw.bb3.i ], [ @capture_edited_filters, %sw.bb2.i ], [ @display_filters, %sw.bb1.i ], [ @capture_filters, %sw.bb.i ] - switch i32 %src_type, label %sw.default.i5 [ - i32 0, label %sw.bb.i1 - i32 1, label %sw.bb1.i2 - i32 2, label %sw.bb2.i3 - i32 3, label %sw.bb3.i4 - ] - -sw.bb.i1: ; preds = %get_filter_list.exit - br label %get_filter_list.exit6 - -sw.bb1.i2: ; preds = %get_filter_list.exit - br label %get_filter_list.exit6 - -sw.bb2.i3: ; preds = %get_filter_list.exit - br label %get_filter_list.exit6 - -sw.bb3.i4: ; preds = %get_filter_list.exit - br label %get_filter_list.exit6 - -sw.default.i5: ; preds = %get_filter_list.exit - call void @g_assertion_message(i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str2, i32 0, i32 0), i32 408, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @__PRETTY_FUNCTION__.get_filter_list, i32 0, i32 0), i8* null) noreturn nounwind - unreachable - -; CHECK: get_filter_list.exit -get_filter_list.exit6: ; preds = %sw.bb3.i4, %sw.bb2.i3, %sw.bb1.i2, %sw.bb.i1 - %1 = phi %struct._GList** [ @display_edited_filters, %sw.bb3.i4 ], [ @capture_edited_filters, %sw.bb2.i3 ], [ @display_filters, %sw.bb1.i2 ], [ @capture_filters, %sw.bb.i1 ] -; CHECK: %2 = load - %2 = load %struct._GList*, %struct._GList** %1, align 8 -; We should have jump-threading insert an additional load here for the value -; coming out of the first switch, which is picked up by a subsequent phi -; CHECK: %.pr = load %struct._GList*, %struct._GList** %0 -; CHECK-NEXT: br label %while.cond - br label %while.cond - -; CHECK: while.cond -while.cond: ; preds = %while.body, %get_filter_list.exit6 -; CHECK: {{= phi .*%.pr}} - %3 = load %struct._GList*, %struct._GList** %0, align 8 -; CHECK: tobool - %tobool = icmp ne %struct._GList* %3, null - br i1 %tobool, label %while.body, label %while.end - -while.body: ; preds = %while.cond - %4 = load %struct._GList*, %struct._GList** %0, align 8 - %5 = load %struct._GList*, %struct._GList** %0, align 8 - %call2 = call %struct._GList* @g_list_first(%struct._GList* %5) - %data.i = getelementptr inbounds %struct._GList, %struct._GList* %call2, i32 0, i32 0 - %6 = load i8*, i8** %data.i, align 8 - %7 = bitcast i8* %6 to %struct.filter_def* - %name.i = getelementptr inbounds %struct.filter_def, %struct.filter_def* %7, i32 0, i32 0 - %8 = load i8*, i8** %name.i, align 8 - call void @g_free(i8* %8) nounwind - %strval.i = getelementptr inbounds %struct.filter_def, %struct.filter_def* %7, i32 0, i32 1 - %9 = load i8*, i8** %strval.i, align 8 - call void @g_free(i8* %9) nounwind - %10 = bitcast %struct.filter_def* %7 to i8* - call void @g_free(i8* %10) nounwind - %call.i = call %struct._GList* @g_list_remove_link(%struct._GList* %4, %struct._GList* %call2) nounwind - store %struct._GList* %call.i, %struct._GList** %0, align 8 - br label %while.cond - -while.end: ; preds = %while.cond - br label %do.body4 - -do.body4: ; preds = %while.end - %11 = load %struct._GList*, %struct._GList** %0, align 8 - %call5 = call i32 @g_list_length(%struct._GList* %11) - %cmp6 = icmp eq i32 %call5, 0 - br i1 %cmp6, label %if.then7, label %if.else8 - -if.then7: ; preds = %do.body4 - br label %if.end9 - -if.else8: ; preds = %do.body4 - call void @g_assertion_message_expr(i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str2, i32 0, i32 0), i32 600, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @__PRETTY_FUNCTION__.copy_filter_list, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str13, i32 0, i32 0)) noreturn - unreachable - -if.end9: ; preds = %if.then7 - br label %do.end10 - -do.end10: ; preds = %if.end9 - br label %while.cond11 - -while.cond11: ; preds = %cond.end, %do.end10 - %cond10 = phi %struct._GList* [ %cond, %cond.end ], [ %2, %do.end10 ] - %tobool12 = icmp ne %struct._GList* %cond10, null - br i1 %tobool12, label %while.body13, label %while.end16 - -while.body13: ; preds = %while.cond11 - %data = getelementptr inbounds %struct._GList, %struct._GList* %cond10, i32 0, i32 0 - %12 = load i8*, i8** %data, align 8 - %13 = bitcast i8* %12 to %struct.filter_def* - %14 = load %struct._GList*, %struct._GList** %0, align 8 - %name = getelementptr inbounds %struct.filter_def, %struct.filter_def* %13, i32 0, i32 0 - %15 = load i8*, i8** %name, align 8 - %strval = getelementptr inbounds %struct.filter_def, %struct.filter_def* %13, i32 0, i32 1 - %16 = load i8*, i8** %strval, align 8 - %call.i7 = call noalias i8* @g_malloc(i64 16) nounwind - %17 = bitcast i8* %call.i7 to %struct.filter_def* - %call1.i = call noalias i8* @g_strdup(i8* %15) nounwind - %name.i8 = getelementptr inbounds %struct.filter_def, %struct.filter_def* %17, i32 0, i32 0 - store i8* %call1.i, i8** %name.i8, align 8 - %call2.i = call noalias i8* @g_strdup(i8* %16) nounwind - %strval.i9 = getelementptr inbounds %struct.filter_def, %struct.filter_def* %17, i32 0, i32 1 - store i8* %call2.i, i8** %strval.i9, align 8 - %18 = bitcast %struct.filter_def* %17 to i8* - %call3.i = call %struct._GList* @g_list_append(%struct._GList* %14, i8* %18) nounwind - store %struct._GList* %call3.i, %struct._GList** %0, align 8 - %tobool15 = icmp ne %struct._GList* %cond10, null - br i1 %tobool15, label %cond.true, label %cond.false - -cond.true: ; preds = %while.body13 - %next = getelementptr inbounds %struct._GList, %struct._GList* %cond10, i32 0, i32 1 - %19 = load %struct._GList*, %struct._GList** %next, align 8 - br label %cond.end - -cond.false: ; preds = %while.body13 - br label %cond.end - -cond.end: ; preds = %cond.false, %cond.true - %cond = phi %struct._GList* [ %19, %cond.true ], [ null, %cond.false ] - br label %while.cond11 - -while.end16: ; preds = %while.cond11 - ret void -} - -declare void @g_assertion_message_expr(i8*, i8*, i32, i8*, i8*) noreturn - -declare i32 @g_list_length(%struct._GList*) - -declare noalias i8* @g_strdup(i8*) - -declare %struct._GList* @g_list_append(%struct._GList*, i8*) - -declare %struct._GList* @g_list_remove_link(%struct._GList*, %struct._GList*) diff --git a/llvm/test/Transforms/JumpThreading/phi-known.ll b/llvm/test/Transforms/JumpThreading/phi-known.ll deleted file mode 100644 index 3473806c0a6..00000000000 --- a/llvm/test/Transforms/JumpThreading/phi-known.ll +++ /dev/null @@ -1,104 +0,0 @@ -; RUN: opt -S -jump-threading %s | FileCheck %s - -; Value of predicate known on all inputs (trivial case) -; Note: InstCombine/EarlyCSE would also get this case -define void @test(i8* %p, i8** %addr) { -; CHECK-LABEL: @test -entry: - %cmp0 = icmp eq i8* %p, null - br i1 %cmp0, label %exit, label %loop -loop: -; CHECK-LABEL: loop: -; CHECK-NEXT: phi -; CHECK-NEXT: br label %loop - %p1 = phi i8* [%p, %entry], [%p1, %loop] - %cmp1 = icmp eq i8* %p1, null - br i1 %cmp1, label %exit, label %loop -exit: - ret void -} - -; Value of predicate known on all inputs (non-trivial) -define void @test2(i8* %p) { -; CHECK-LABEL: @test2 -entry: - %cmp0 = icmp eq i8* %p, null - br i1 %cmp0, label %exit, label %loop -loop: - %p1 = phi i8* [%p, %entry], [%p2, %backedge] - %cmp1 = icmp eq i8* %p1, null - br i1 %cmp1, label %exit, label %backedge -backedge: -; CHECK-LABEL: backedge: -; CHECK-NEXT: phi -; CHECK-NEXT: bitcast -; CHECK-NEXT: load -; CHECK-NEXT: cmp -; CHECK-NEXT: br -; CHECK-DAG: label %backedge - %addr = bitcast i8* %p1 to i8** - %p2 = load i8*, i8** %addr - %cmp2 = icmp eq i8* %p2, null - br i1 %cmp2, label %exit, label %loop -exit: - ret void -} - -; If the inputs don't branch the same way, we can't rewrite -; Well, we could unroll this loop exactly twice, but that's -; a different transform. -define void @test_mixed(i8* %p) { -; CHECK-LABEL: @test_mixed -entry: - %cmp0 = icmp eq i8* %p, null - br i1 %cmp0, label %exit, label %loop -loop: -; CHECK-LABEL: loop: -; CHECK-NEXT: phi -; CHECK-NEXT: %cmp1 = icmp -; CHECK-NEXT: br i1 %cmp1 - %p1 = phi i8* [%p, %entry], [%p1, %loop] - %cmp1 = icmp ne i8* %p1, null - br i1 %cmp1, label %exit, label %loop -exit: - ret void -} - -; The eq predicate is always true if we go through the path from -; L1 to L3, no matter the phi result %t5 is on the lhs or rhs of -; the predicate. -declare void @goo() -declare void @hoo() - -define void @test3(i32 %m, i32** %t1) { -L1: - %t0 = add i32 %m, 7 - %t2 = load i32*, i32** %t1, align 8 -; CHECK-LABEL: @test3 -; CHECK: %t3 = icmp eq i32* %t2, null -; CHECK: br i1 %t3, label %[[LABEL2:.*]], label %[[LABEL1:.*]] - - %t3 = icmp eq i32* %t2, null - br i1 %t3, label %L3, label %L2 - -; CHECK: [[LABEL1]]: -; CHECK-NEXT: %t4 = load i32, i32* %t2, align 4 -L2: - %t4 = load i32, i32* %t2, align 4 - br label %L3 - -L3: - %t5 = phi i32 [ %t0, %L1 ], [ %t4, %L2 ] - %t6 = icmp eq i32 %t0, %t5 - br i1 %t6, label %L4, label %L5 - -; CHECK: [[LABEL2]]: -; CHECK-NEXT: call void @goo() -L4: - call void @goo() - ret void - -L5: - call void @hoo() - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/pr15851_hang.ll b/llvm/test/Transforms/JumpThreading/pr15851_hang.ll deleted file mode 100644 index 41ca9512dcb..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr15851_hang.ll +++ /dev/null @@ -1,32 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - -; CHECK-LABEL: @f( -; CHECK-LABEL: entry -; CHECK-NEXT: ret void -; -; JumpThreading must detect the next two blocks are unreachable from entry -; and leave them alone. A subsequent pass will remove them from @f. -; -; CHECK: for.cond1: -; CHECK-NEXT: phi -; CHECK-NEXT: icmp -; CHECK-NEXT: br i1 %cmp, label %for.body, label %for.cond1 -; CHECK: for.body: -; CHECK-NEXT: add -; CHECK-NEXT: icmp -; CHECK-NEXT: br i1 %a, label %for.cond1, label %for.cond1 - -define void @f() { -entry: - ret void - -for.cond1: - %i.025 = phi i32 [ %inc, %for.body ], [ %inc, %for.body ], [ 1, %for.cond1 ] - %cmp = icmp slt i32 %i.025, 2 - br i1 %cmp, label %for.body, label %for.cond1 - -for.body: - %inc = add nsw i32 %i.025, 0 - %a = icmp ugt i32 %inc, 2 - br i1 %a, label %for.cond1, label %for.cond1 -} diff --git a/llvm/test/Transforms/JumpThreading/pr22086.ll b/llvm/test/Transforms/JumpThreading/pr22086.ll deleted file mode 100644 index 35d9aa5b184..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr22086.ll +++ /dev/null @@ -1,28 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - - -; CHECK-LABEL: @f( -; CHECK-LABEL: entry: -; CHECK-NEXT: br label %[[loop:.*]] -; CHECK: [[loop]]: -; CHECK-NEXT: br label %[[loop]] - -define void @f() { -entry: - br label %for.cond1 - -if.end16: - %phi1 = phi i32 [ undef, %for.cond1 ] - %g.3 = phi i32 [ %g.1, %for.cond1 ] - %sext = shl i32 %g.3, 16 - %conv20 = ashr exact i32 %sext, 16 - %tobool21 = icmp eq i32 %phi1, 0 - br i1 %tobool21, label %lor.rhs, label %for.cond1 - -for.cond1: - %g.1 = phi i32 [ 0, %entry ], [ 0, %lor.rhs ], [ %g.3, %if.end16 ] - br i1 undef, label %lor.rhs, label %if.end16 - -lor.rhs: - br label %for.cond1 -} diff --git a/llvm/test/Transforms/JumpThreading/pr26096.ll b/llvm/test/Transforms/JumpThreading/pr26096.ll deleted file mode 100644 index 096d43e24d2..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr26096.ll +++ /dev/null @@ -1,73 +0,0 @@ -; RUN: opt -prune-eh -inline -jump-threading -S < %s | FileCheck %s - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -@d = external global i32*, align 8 - -define void @fn3(i1 %B) { -entry: - br i1 %B, label %if.end, label %if.then - -if.then: ; preds = %entry - call void @fn2(i1 %B) - ret void - -if.end: ; preds = %entry - call void @fn2(i1 %B) - ret void -} - -define internal void @fn2(i1 %B) unnamed_addr { -entry: - call void @fn1() - call void @fn1() - call void @fn1() - br i1 %B, label %if.end, label %if.then -if.then: - unreachable - -if.end: - unreachable -} - -; CHECK-LABEL: define internal void @fn2( -; CHECK: %[[LOAD:.*]] = load i32*, i32** @d, align 8 -; CHECK: %tobool1.i = icmp eq i32* %[[LOAD]], null - -define internal void @fn1() unnamed_addr { -entry: - br label %for.body - -for.body: ; preds = %entry - %0 = load i32*, i32** @d, align 8 - %tobool1 = icmp eq i32* %0, null - br i1 %tobool1, label %cond.false, label %cond.end - -cond.false: ; preds = %for.body - call void @__assert_fail(i8* null) - unreachable - -cond.end: ; preds = %for.body - %1 = load i32*, i32** @d, align 8 - %cmp = icmp eq i32* %1, null - br i1 %cmp, label %cond.end4, label %cond.false3 - -cond.false3: ; preds = %cond.end - call void @__assert_fail(i8* null) - unreachable - -cond.end4: ; preds = %cond.end - call void @__assert_fail(i8* null) - unreachable - -for.end: ; No predecessors! - ret void -} - -declare void @__assert_fail(i8*) - -; Function Attrs: noreturn nounwind -declare void @llvm.trap() #0 - -attributes #0 = { noreturn nounwind } diff --git a/llvm/test/Transforms/JumpThreading/pr27840.ll b/llvm/test/Transforms/JumpThreading/pr27840.ll deleted file mode 100644 index cbee2af67fa..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr27840.ll +++ /dev/null @@ -1,33 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s - -target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-apple-macosx10.11.0" - -declare void @helper() -declare i32 @__gxx_personality_v0(...) - - -define void @pr27840(i8* %call, i1 %A) personality i32(...)* @__gxx_personality_v0 { -entry: - invoke void @helper() - to label %invoke.cont unwind label %lpad - -; Don't jump threading; we can't split the critical edge from entry to lpad. -; CHECK-LABEL: @pr27840 -; CHECK: invoke -; CHECK-NEXT: to label %invoke.cont unwind label %lpad - -invoke.cont: - invoke void @helper() - to label %nowhere unwind label %lpad - -lpad: - %b = phi i1 [ true, %invoke.cont ], [ false, %entry ] - landingpad { i8*, i32 } - cleanup - %xor = xor i1 %b, %A - br i1 %xor, label %nowhere, label %invoke.cont - -nowhere: - unreachable -} diff --git a/llvm/test/Transforms/JumpThreading/pr33605.ll b/llvm/test/Transforms/JumpThreading/pr33605.ll deleted file mode 100644 index eb8cab90fa5..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr33605.ll +++ /dev/null @@ -1,64 +0,0 @@ -; RUN: opt < %s -jump-threading -S | FileCheck %s - -; Skip simplifying unconditional branches from empty blocks in simplifyCFG, -; when it can destroy canonical loop structure. - -; void foo(); -; bool test(int a, int b, int *c) { -; bool changed = false; -; for (unsigned int i = 2; i--;) { -; int r = a | b; -; if ( r != c[i]) { -; c[i] = r; -; foo(); -; changed = true; -; } -; } -; return changed; -; } - -; CHECK-LABEL: @test( -; CHECK: for.cond: -; CHECK-NEXT: %i.0 = phi i32 [ 2, %entry ], [ %dec, %if.end ] -; CHECK: for.body: -; CHECK: br i1 %cmp, label %if.end, label %if.then -; CHECK-NOT: br i1 %cmp, label %for.cond, label %if.then -; CHECK: if.then: -; CHECK: br label %if.end -; CHECK-NOT: br label %for.cond -; CHECK: if.end: -; CHECK br label %for.cond -define i1 @test(i32 %a, i32 %b, i32* %c) { -entry: - br label %for.cond - -for.cond: ; preds = %if.end, %entry - %i.0 = phi i32 [ 2, %entry ], [ %dec, %if.end ] - %changed.0.off0 = phi i1 [ false, %entry ], [ %changed.1.off0, %if.end ] - %dec = add nsw i32 %i.0, -1 - %tobool = icmp eq i32 %i.0, 0 - br i1 %tobool, label %for.cond.cleanup, label %for.body - -for.cond.cleanup: ; preds = %for.cond - %changed.0.off0.lcssa = phi i1 [ %changed.0.off0, %for.cond ] - ret i1 %changed.0.off0.lcssa - -for.body: ; preds = %for.cond - %or = or i32 %a, %b - %idxprom = sext i32 %dec to i64 - %arrayidx = getelementptr inbounds i32, i32* %c, i64 %idxprom - %0 = load i32, i32* %arrayidx, align 4 - %cmp = icmp eq i32 %or, %0 - br i1 %cmp, label %if.end, label %if.then - -if.then: ; preds = %for.body - store i32 %or, i32* %arrayidx, align 4 - call void @foo() - br label %if.end - -if.end: ; preds = %for.body, %if.then - %changed.1.off0 = phi i1 [ true, %if.then ], [ %changed.0.off0, %for.body ] - br label %for.cond -} - -declare void @foo() diff --git a/llvm/test/Transforms/JumpThreading/pr33917.ll b/llvm/test/Transforms/JumpThreading/pr33917.ll deleted file mode 100644 index 30652279a0e..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr33917.ll +++ /dev/null @@ -1,57 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -jump-threading -correlated-propagation %s -S | FileCheck %s - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -declare i8* @foo() - -declare i32 @rust_eh_personality() unnamed_addr - -; Function Attrs: nounwind -declare void @llvm.assume(i1) #0 - -define void @patatino() personality i32 ()* @rust_eh_personality { -; CHECK-LABEL: @patatino( -; CHECK-NEXT: bb9: -; CHECK-NEXT: [[T9:%.*]] = invoke i8* @foo() -; CHECK-NEXT: to label [[GOOD:%.*]] unwind label [[BAD:%.*]] -; CHECK: bad: -; CHECK-NEXT: [[T10:%.*]] = landingpad { i8*, i32 } -; CHECK-NEXT: cleanup -; CHECK-NEXT: resume { i8*, i32 } [[T10]] -; CHECK: good: -; CHECK-NEXT: [[T11:%.*]] = icmp ne i8* [[T9]], null -; CHECK-NEXT: [[T12:%.*]] = zext i1 [[T11]] to i64 -; CHECK-NEXT: [[COND:%.*]] = icmp eq i64 [[T12]], 1 -; CHECK-NEXT: br i1 [[COND]], label [[IF_TRUE:%.*]], label [[DONE:%.*]] -; CHECK: if_true: -; CHECK-NEXT: call void @llvm.assume(i1 [[T11]]) -; CHECK-NEXT: br label [[DONE]] -; CHECK: done: -; CHECK-NEXT: ret void -; -bb9: - %t9 = invoke i8* @foo() - to label %good unwind label %bad - -bad: - %t10 = landingpad { i8*, i32 } - cleanup - resume { i8*, i32 } %t10 - -good: - %t11 = icmp ne i8* %t9, null - %t12 = zext i1 %t11 to i64 - %cond = icmp eq i64 %t12, 1 - br i1 %cond, label %if_true, label %done - -if_true: - call void @llvm.assume(i1 %t11) - br label %done - -done: - ret void -} - -attributes #0 = { nounwind } diff --git a/llvm/test/Transforms/JumpThreading/pr36133.ll b/llvm/test/Transforms/JumpThreading/pr36133.ll deleted file mode 100644 index b8d8c5fac46..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr36133.ll +++ /dev/null @@ -1,44 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s -@global = external global i8*, align 8 - -define i32 @foo(i32 %arg) { -; CHECK-LABEL: @foo -; CHECK-LABEL: bb: -; CHECK: icmp eq -; CHECK-NEXT: br i1 %tmp1, label %bb7, label %bb7 -bb: - %tmp = load i8*, i8** @global, align 8 - %tmp1 = icmp eq i8* %tmp, null - br i1 %tmp1, label %bb3, label %bb2 - -; CHECK-NOT: bb2: -bb2: - br label %bb3 - -; CHECK-NOT: bb3: -bb3: - %tmp4 = phi i8 [ 1, %bb2 ], [ 0, %bb ] - %tmp5 = icmp eq i8 %tmp4, 0 - br i1 %tmp5, label %bb7, label %bb6 - -; CHECK-NOT: bb6: -bb6: - br label %bb7 - -; CHECK-LABEL: bb7: -bb7: - %tmp8 = icmp eq i32 %arg, -1 - br i1 %tmp8, label %bb9, label %bb10 - -; CHECK-LABEL: bb9: -bb9: - ret i32 0 - -; CHECK-LABEL: bb10: -bb10: - %tmp11 = icmp sgt i32 %arg, -1 - call void @llvm.assume(i1 %tmp11) - ret i32 1 -} - -declare void @llvm.assume(i1) diff --git a/llvm/test/Transforms/JumpThreading/pr40992-indirectbr-folding.ll b/llvm/test/Transforms/JumpThreading/pr40992-indirectbr-folding.ll deleted file mode 100644 index b94d4c1b701..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr40992-indirectbr-folding.ll +++ /dev/null @@ -1,44 +0,0 @@ -; RUN: opt -S < %s -jump-threading | FileCheck %s - -; PR40992: Do not incorrectly fold %bb5 into an unconditional br to %bb7. -; Also verify we correctly thread %bb1 -> %bb7 when %c is false. - -define i32 @jtbr(i1 %v1, i1 %v2, i1 %v3) { -; CHECK: bb0: -bb0: - br label %bb1 - -; CHECK: bb1: -; CHECK-NEXT: and -; CHECK-NEXT: br i1 %c, label %bb2, label %bb7 -bb1: - %c = and i1 %v1, %v2 - br i1 %c, label %bb2, label %bb5 - -; CHECK: bb2: -; CHECK-NEXT: select -; CHECK-NEXT: indirectbr i8* %ba, [label %bb3, label %bb5] -bb2: - %ba = select i1 %v3, i8* blockaddress(@jtbr, %bb3), i8* blockaddress(@jtbr, %bb4) - indirectbr i8* %ba, [label %bb3, label %bb4] - -; CHECK: bb3: -bb3: - br label %bb1 - -; CHECK-NOT: bb4: -bb4: - br label %bb5 - -; CHECK: bb5: -bb5: - br i1 %c, label %bb6, label %bb7 - -; CHECK: bb6: -bb6: - ret i32 0 - -; CHECK: bb7: -bb7: - ret i32 1 -} diff --git a/llvm/test/Transforms/JumpThreading/pr9331.ll b/llvm/test/Transforms/JumpThreading/pr9331.ll deleted file mode 100644 index 4c06d526ca1..00000000000 --- a/llvm/test/Transforms/JumpThreading/pr9331.ll +++ /dev/null @@ -1,50 +0,0 @@ -; RUN: opt -jump-threading -S < %s - -define void @func(i8 zeroext %p_44) nounwind { -entry: - br i1 false, label %for.cond2, label %if.end50 - -for.cond2: ; preds = %for.inc46, %lor.end, %entry - %p_44.addr.1 = phi i8 [ %p_44.addr.1, %lor.end ], [ %p_44, %entry ], [ %p_44.addr.1, %for.inc46 ] - br i1 undef, label %for.inc46, label %for.body5 - -for.body5: ; preds = %for.cond2 - br i1 undef, label %lbl_465, label %if.then9 - -if.then9: ; preds = %for.body5 - br label %return - -lbl_465: ; preds = %lbl_465, %for.body5 - %tobool19 = icmp eq i8 undef, 0 - br i1 %tobool19, label %if.end21, label %lbl_465 - -if.end21: ; preds = %lbl_465 - %conv23 = zext i8 %p_44.addr.1 to i64 - %xor = xor i64 %conv23, 1 - %tobool.i = icmp eq i64 %conv23, 0 - br i1 %tobool.i, label %cond.false.i, label %safe_mod_func_uint64_t_u_u.exit - -cond.false.i: ; preds = %if.end21 - %div.i = udiv i64 %xor, %conv23 - br label %safe_mod_func_uint64_t_u_u.exit - -safe_mod_func_uint64_t_u_u.exit: ; preds = %cond.false.i, %if.end21 - %cond.i = phi i64 [ %div.i, %cond.false.i ], [ %conv23, %if.end21 ] - %tobool28 = icmp eq i64 %cond.i, 0 - br i1 %tobool28, label %lor.rhs, label %lor.end - -lor.rhs: ; preds = %safe_mod_func_uint64_t_u_u.exit - br label %lor.end - -lor.end: ; preds = %lor.rhs, %safe_mod_func_uint64_t_u_u.exit - br label %for.cond2 - -for.inc46: ; preds = %for.cond2 - br label %for.cond2 - -if.end50: ; preds = %entry - br label %return - -return: ; preds = %if.end50, %if.then9 - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/range-compare.ll b/llvm/test/Transforms/JumpThreading/range-compare.ll deleted file mode 100644 index 54e94d06649..00000000000 --- a/llvm/test/Transforms/JumpThreading/range-compare.ll +++ /dev/null @@ -1,125 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -;RUN: opt < %s -jump-threading -S | FileCheck %s - - -declare void @bar(...) -declare void @baz(...) - -; Make sure we thread the end of the bar block to the end of the function. -define void @test1(i32 %x) { -; CHECK-LABEL: @test1( -; CHECK-NEXT: entry: -; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 9 -; CHECK-NEXT: br i1 [[CMP]], label [[IF_END_THREAD:%.*]], label [[IF_END:%.*]] -; CHECK: if.end.thread: -; CHECK-NEXT: call void (...) @bar() -; CHECK-NEXT: br label [[IF_END4:%.*]] -; CHECK: if.end: -; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 -; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 -; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN3:%.*]], label [[IF_END4]] -; CHECK: if.then3: -; CHECK-NEXT: call void (...) @baz() -; CHECK-NEXT: br label [[IF_END4]] -; CHECK: if.end4: -; CHECK-NEXT: ret void -; -entry: - %cmp = icmp sgt i32 %x, 9 - br i1 %cmp, label %if.then, label %if.end - -if.then: ; preds = %entry - call void (...) @bar() - br label %if.end - -if.end: ; preds = %if.then, %entry - %x.off = add i32 %x, -3 - %0 = icmp ult i32 %x.off, 5 - br i1 %0, label %if.then3, label %if.end4 - -if.then3: ; preds = %if.end - call void (...) @baz() - br label %if.end4 - -if.end4: ; preds = %if.then3, %if.end - ret void -} - -; Make sure we thread the false side of the first if to the end of the function. -define void @test2(i32 %x) { -; CHECK-LABEL: @test2( -; CHECK-NEXT: entry: -; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 9 -; CHECK-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_END4:%.*]] -; CHECK: if.end: -; CHECK-NEXT: call void (...) @bar() -; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 -; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 -; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN3:%.*]], label [[IF_END4]] -; CHECK: if.then3: -; CHECK-NEXT: call void (...) @baz() -; CHECK-NEXT: br label [[IF_END4]] -; CHECK: if.end4: -; CHECK-NEXT: ret void -; -entry: - %cmp = icmp slt i32 %x, 9 - br i1 %cmp, label %if.then, label %if.end - -if.then: ; preds = %entry - call void (...) @bar() - br label %if.end - -if.end: ; preds = %if.then, %entry - %x.off = add i32 %x, -3 - %0 = icmp ult i32 %x.off, 5 - br i1 %0, label %if.then3, label %if.end4 - -if.then3: ; preds = %if.end - call void (...) @baz() - br label %if.end4 - -if.end4: ; preds = %if.then3, %if.end - ret void -} - -; Negative test to make sure we don't thread when the ranges overlap. -define void @test3(i32 %x) { -; CHECK-LABEL: @test3( -; CHECK-NEXT: entry: -; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 6 -; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] -; CHECK: if.then: -; CHECK-NEXT: call void (...) @bar() -; CHECK-NEXT: br label [[IF_END]] -; CHECK: if.end: -; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 -; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 -; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN3:%.*]], label [[IF_END4:%.*]] -; CHECK: if.then3: -; CHECK-NEXT: call void (...) @baz() -; CHECK-NEXT: br label [[IF_END4]] -; CHECK: if.end4: -; CHECK-NEXT: ret void -; -entry: - %cmp = icmp sgt i32 %x, 6 - br i1 %cmp, label %if.then, label %if.end - -if.then: ; preds = %entry - call void (...) @bar() - br label %if.end - -if.end: ; preds = %if.then, %entry - %x.off = add i32 %x, -3 - %0 = icmp ult i32 %x.off, 5 - br i1 %0, label %if.then3, label %if.end4 - -if.then3: ; preds = %if.end - call void (...) @baz() - br label %if.end4 - -if.end4: ; preds = %if.then3, %if.end - ret void -} - diff --git a/llvm/test/Transforms/JumpThreading/removed-use.ll b/llvm/test/Transforms/JumpThreading/removed-use.ll deleted file mode 100644 index bc97429cbae..00000000000 --- a/llvm/test/Transforms/JumpThreading/removed-use.ll +++ /dev/null @@ -1,54 +0,0 @@ -; RUN: opt -S < %s -jump-threading | FileCheck %s -; CHECK-LABEL: @foo -; CHECK: bb6: -; CHECK-NEXT: ret void -; CHECK: bb3: -; CHECK: br label %bb3 -define void @foo() { -entry: - br i1 true, label %bb6, label %bb3 - -bb3: - %x0 = phi i32 [ undef, %entry ], [ %x1, %bb5 ] - %y = and i64 undef, 1 - %p = icmp ne i64 %y, 0 - br i1 %p, label %bb4, label %bb5 - -bb4: - br label %bb5 - -bb5: - %x1 = phi i32 [ %x0, %bb3 ], [ %x0, %bb4 ] - %z = phi i32 [ 0, %bb3 ], [ 1, %bb4 ] - %q = icmp eq i32 %z, 0 - br i1 %q, label %bb3, label %bb6 - -bb6: - ret void -} - -; CHECK-LABEL: @bar -; Just check that we don't crash on this test. -define void @bar(i1 %p) { -entry: - br i1 false, label %bb2, label %exit - -bb2: - %x0 = phi i32 [ undef, %entry ], [ %x1, %bb5 ] - br i1 %p, label %bb3, label %bb4 - -bb3: - br label %bb5 - -bb4: - br label %bb5 - -bb5: - %x1 = phi i32 [ %x0, %bb3 ], [ 0, %bb4 ] - switch i32 %x1, label %exit [ - i32 10, label %bb2 - ] - -exit: - ret void -} diff --git a/llvm/test/Transforms/JumpThreading/select.ll b/llvm/test/Transforms/JumpThreading/select.ll deleted file mode 100644 index 7557a6c814b..00000000000 --- a/llvm/test/Transforms/JumpThreading/select.ll +++ /dev/null @@ -1,443 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - -declare void @foo() -declare void @bar() -declare void @baz() -declare void @quux() - - -; Jump threading of branch with select as condition. -; Mostly theoretical since instruction combining simplifies all selects of -; booleans where at least one operand is true/false/undef. - -; CHECK-LABEL: @test_br( -; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %cond, label %L1, -define void @test_br(i1 %cond, i1 %value) nounwind { -entry: - br i1 %cond, label %L0, label %L3 -L0: - %expr = select i1 %cond, i1 true, i1 %value - br i1 %expr, label %L1, label %L2 - -L1: - call void @foo() - ret void -L2: - call void @bar() - ret void -L3: - call void @baz() - br label %L0 -} - - -; Jump threading of switch with select as condition. - -; CHECK-LABEL: @test_switch( -; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %cond, label %L1, -define void @test_switch(i1 %cond, i8 %value) nounwind { -entry: - br i1 %cond, label %L0, label %L4 -L0: - %expr = select i1 %cond, i8 1, i8 %value - switch i8 %expr, label %L3 [i8 1, label %L1 i8 2, label %L2] - -L1: - call void @foo() - ret void -L2: - call void @bar() - ret void -L3: - call void @baz() - ret void -L4: - call void @quux() - br label %L0 -} - -; Make sure the blocks in the indirectbr test aren't trivially removable as -; successors by taking their addresses. -@anchor = constant [3 x i8*] [ - i8* blockaddress(@test_indirectbr, %L1), - i8* blockaddress(@test_indirectbr, %L2), - i8* blockaddress(@test_indirectbr, %L3) -] - - -; Jump threading of indirectbr with select as address. - -; CHECK-LABEL: @test_indirectbr( -; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %cond, label %L1, label %L3 -define void @test_indirectbr(i1 %cond, i8* %address) nounwind { -entry: - br i1 %cond, label %L0, label %L3 -L0: - %indirect.goto.dest = select i1 %cond, i8* blockaddress(@test_indirectbr, %L1), i8* %address - indirectbr i8* %indirect.goto.dest, [label %L1, label %L2, label %L3] - -L1: - call void @foo() - ret void -L2: - call void @bar() - ret void -L3: - call void @baz() - ret void -} - - -; Jump threading of indirectbr with select as address. Test increased -; duplication threshold for cases where indirectbr is being threaded -; through. - -; CHECK-LABEL: @test_indirectbr_thresh( -; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %cond, label %L1, label %L3 -; CHECK-NOT: indirectbr -define void @test_indirectbr_thresh(i1 %cond, i8* %address) nounwind { -entry: - br i1 %cond, label %L0, label %L3 -L0: - %indirect.goto.dest = select i1 %cond, i8* blockaddress(@test_indirectbr_thresh, %L1), i8* %address - call void @quux() - call void @quux() - call void @quux() - indirectbr i8* %indirect.goto.dest, [label %L1, label %L2, label %L3] - -L1: - call void @foo() - ret void -L2: - call void @bar() - ret void -L3: - call void @baz() - ret void -} - - -; A more complicated case: the condition is a select based on a comparison. - -; CHECK-LABEL: @test_switch_cmp( -; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %cond, label %L0, label %[[THREADED:[A-Za-z.0-9]+]] -; CHECK: [[THREADED]]: -; CHECK-NEXT: call void @quux -; CHECK-NEXT: br label %L1 -define void @test_switch_cmp(i1 %cond, i32 %val, i8 %value) nounwind { -entry: - br i1 %cond, label %L0, label %L4 -L0: - %val.phi = phi i32 [%val, %entry], [-1, %L4] - %cmp = icmp slt i32 %val.phi, 0 - %expr = select i1 %cmp, i8 1, i8 %value - switch i8 %expr, label %L3 [i8 1, label %L1 i8 2, label %L2] - -L1: - call void @foo() - ret void -L2: - call void @bar() - ret void -L3: - call void @baz() - ret void -L4: - call void @quux() - br label %L0 -} - -; Make sure the edge value of %0 from entry to L2 includes 0 and L3 is -; reachable. -; CHECK: test_switch_default -; CHECK: entry: -; CHECK: load -; CHECK: switch -; CHECK: [[THREADED:[A-Za-z.0-9]+]]: -; CHECK: store -; CHECK: br -; CHECK: L2: -; CHECK-SAME: preds = %entry, %entry -; CHECK-NEXT: phi i32 -define void @test_switch_default(i32* nocapture %status) nounwind { -entry: - %0 = load i32, i32* %status, align 4 - switch i32 %0, label %L2 [ - i32 5061, label %L1 - i32 0, label %L2 - ] - -L1: - store i32 10025, i32* %status, align 4 - br label %L2 - -L2: - %1 = load i32, i32* %status, align 4 - %cmp57.i = icmp eq i32 %1, 0 - br i1 %cmp57.i, label %L3, label %L4 - -L3: - store i32 10000, i32* %status, align 4 - br label %L4 - -L4: - ret void -} - -define void @unfold1(double %x, double %y) nounwind { -entry: - %sub = fsub double %x, %y - %cmp = fcmp ogt double %sub, 1.000000e+01 - br i1 %cmp, label %cond.end4, label %cond.false - -cond.false: ; preds = %entry - %add = fadd double %x, %y - %cmp1 = fcmp ogt double %add, 1.000000e+01 - %add. = select i1 %cmp1, double %add, double 0.000000e+00 - br label %cond.end4 - -cond.end4: ; preds = %entry, %cond.false - %cond5 = phi double [ %add., %cond.false ], [ %sub, %entry ] - %cmp6 = fcmp oeq double %cond5, 0.000000e+00 - br i1 %cmp6, label %if.then, label %if.end - -if.then: ; preds = %cond.end4 - call void @foo() - br label %if.end - -if.end: ; preds = %if.then, %cond.end4 - ret void - -; CHECK-LABEL: @unfold1 -; CHECK: br i1 %cmp, label %cond.end4, label %cond.false -; CHECK: br i1 %cmp1, label %cond.end4, label %if.then -; CHECK: br i1 %cmp6, label %if.then, label %if.end -; CHECK: br label %if.end -} - - -define void @unfold2(i32 %x, i32 %y) nounwind { -entry: - %sub = sub nsw i32 %x, %y - %cmp = icmp sgt i32 %sub, 10 - br i1 %cmp, label %cond.end4, label %cond.false - -cond.false: ; preds = %entry - %add = add nsw i32 %x, %y - %cmp1 = icmp sgt i32 %add, 10 - %add. = select i1 %cmp1, i32 0, i32 %add - br label %cond.end4 - -cond.end4: ; preds = %entry, %cond.false - %cond5 = phi i32 [ %add., %cond.false ], [ %sub, %entry ] - %cmp6 = icmp eq i32 %cond5, 0 - br i1 %cmp6, label %if.then, label %if.end - -if.then: ; preds = %cond.end4 - call void @foo() - br label %if.end - -if.end: ; preds = %if.then, %cond.end4 - ret void - -; CHECK-LABEL: @unfold2 -; CHECK: br i1 %cmp, label %if.end, label %cond.false -; CHECK: br i1 %cmp1, label %if.then, label %cond.end4 -; CHECK: br i1 %cmp6, label %if.then, label %if.end -; CHECK: br label %if.end -} - - -define i32 @unfold3(i32 %u, i32 %v, i32 %w, i32 %x, i32 %y, i32 %z, i32 %j) nounwind { -entry: - %add3 = add nsw i32 %j, 2 - %cmp.i = icmp slt i32 %u, %v - br i1 %cmp.i, label %.exit, label %cond.false.i - -cond.false.i: ; preds = %entry - %cmp4.i = icmp sgt i32 %u, %v - br i1 %cmp4.i, label %.exit, label %cond.false.6.i - -cond.false.6.i: ; preds = %cond.false.i - %cmp8.i = icmp slt i32 %w, %x - br i1 %cmp8.i, label %.exit, label %cond.false.10.i - -cond.false.10.i: ; preds = %cond.false.6.i - %cmp13.i = icmp sgt i32 %w, %x - br i1 %cmp13.i, label %.exit, label %cond.false.15.i - -cond.false.15.i: ; preds = %cond.false.10.i - %phitmp = icmp sge i32 %y, %z - br label %.exit - -.exit: ; preds = %entry, %cond.false.i, %cond.false.6.i, %cond.false.10.i, %cond.false.15.i - %cond23.i = phi i1 [ false, %entry ], [ true, %cond.false.i ], [ false, %cond.false.6.i ], [ %phitmp, %cond.false.15.i ], [ true, %cond.false.10.i ] - %j.add3 = select i1 %cond23.i, i32 %j, i32 %add3 - ret i32 %j.add3 - -; CHECK-LABEL: @unfold3 -; CHECK: br i1 %cmp.i, label %.exit.thread2, label %cond.false.i -; CHECK: br i1 %cmp4.i, label %.exit.thread, label %cond.false.6.i -; CHECK: br i1 %cmp8.i, label %.exit.thread2, label %cond.false.10.i -; CHECK: br i1 %cmp13.i, label %.exit.thread, label %.exit -; CHECK: br i1 %phitmp, label %.exit.thread, label %.exit.thread2 -; CHECK: br label %.exit.thread2 -} - -define i32 @unfold4(i32 %u, i32 %v, i32 %w, i32 %x, i32 %y, i32 %z, i32 %j) nounwind { -entry: - %add3 = add nsw i32 %j, 2 - %cmp.i = icmp slt i32 %u, %v - br i1 %cmp.i, label %.exit, label %cond.false.i - -cond.false.i: ; preds = %entry - %cmp4.i = icmp sgt i32 %u, %v - br i1 %cmp4.i, label %.exit, label %cond.false.6.i - -cond.false.6.i: ; preds = %cond.false.i - %cmp8.i = icmp slt i32 %w, %x - br i1 %cmp8.i, label %.exit, label %cond.false.10.i - -cond.false.10.i: ; preds = %cond.false.6.i - %cmp13.i = icmp sgt i32 %w, %x - br i1 %cmp13.i, label %.exit, label %cond.false.15.i - -cond.false.15.i: ; preds = %cond.false.10.i - %cmp19.i = icmp sge i32 %y, %z - %conv = zext i1 %cmp19.i to i32 - br label %.exit - -.exit: ; preds = %entry, %cond.false.i, %cond.false.6.i, %cond.false.10.i, %cond.false.15.i - %cond23.i = phi i32 [ 1, %entry ], [ 0, %cond.false.i ], [ 1, %cond.false.6.i ], [ %conv, %cond.false.15.i ], [ 0, %cond.false.10.i ] - %lnot.i18 = icmp eq i32 %cond23.i, 1 - %j.add3 = select i1 %lnot.i18, i32 %j, i32 %add3 - ret i32 %j.add3 - -; CHECK-LABEL: @unfold4 -; CHECK: br i1 %cmp.i, label %.exit.thread, label %cond.false.i -; CHECK: br i1 %cmp4.i, label %.exit.thread3, label %cond.false.6.i -; CHECK: br i1 %cmp8.i, label %.exit.thread, label %cond.false.10.i -; CHECK: br i1 %cmp13.i, label %.exit.thread3, label %.exit -; CHECK: br i1 %lnot.i18, label %.exit.thread, label %.exit.thread3 -; CHECK: br label %.exit.thread3 -} - -define i32 @unfold5(i32 %u, i32 %v, i32 %w, i32 %x, i32 %y, i32 %z, i32 %j) nounwind { -entry: - %add3 = add nsw i32 %j, 2 - %cmp.i = icmp slt i32 %u, %v - br i1 %cmp.i, label %.exit, label %cond.false.i - -cond.false.i: ; preds = %entry - %cmp4.i = icmp sgt i32 %u, %v - br i1 %cmp4.i, label %.exit, label %cond.false.6.i - -cond.false.6.i: ; preds = %cond.false.i - %cmp8.i = icmp slt i32 %w, %x - br i1 %cmp8.i, label %.exit, label %cond.false.10.i - -cond.false.10.i: ; preds = %cond.false.6.i - %cmp13.i = icmp sgt i32 %w, %x - br i1 %cmp13.i, label %.exit, label %cond.false.15.i - -cond.false.15.i: ; preds = %cond.false.10.i - %cmp19.i = icmp sge i32 %y, %z - %conv = zext i1 %cmp19.i to i32 - br label %.exit - -.exit: ; preds = %entry, %cond.false.i, %cond.false.6.i, %cond.false.10.i, %cond.false.15.i - %cond23.i = phi i32 [ 2, %entry ], [ 3, %cond.false.i ], [ 1, %cond.false.6.i ], [ %conv, %cond.false.15.i ], [ 7, %cond.false.10.i ] - %lnot.i18 = icmp sgt i32 %cond23.i, 5 - %j.add3 = select i1 %lnot.i18, i32 %j, i32 %cond23.i - ret i32 %j.add3 - -; CHECK-LABEL: @unfold5 -; CHECK: br i1 %cmp.i, label %.exit, label %cond.false.i -; CHECK: br i1 %cmp4.i, label %.exit, label %cond.false.6.i -; CHECK: br i1 %cmp8.i, label %.exit, label %cond.false.10.i -; CHECK: br i1 %cmp13.i, label %.exit, label %cond.false.15.i -; CHECK: br label %.exit -} - -; When a select has a constant operand in one branch, and it feeds a phi node -; and the phi node feeds a switch we unfold the select -define void @test_func(i32* nocapture readonly %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %n) local_unnamed_addr #0 { -entry: - br label %for.cond - -for.cond: ; preds = %sw.default, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %sw.default ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.cond.cleanup - -for.cond.cleanup: ; preds = %for.cond - ret void - -for.body: ; preds = %for.cond - %0 = zext i32 %i.0 to i64 - %arrayidx = getelementptr inbounds i32, i32* %a, i64 %0 - %1 = load i32, i32* %arrayidx, align 4 - %cmp1 = icmp eq i32 %1, 4 - br i1 %cmp1, label %land.lhs.true, label %if.end - -land.lhs.true: ; preds = %for.body - %arrayidx3 = getelementptr inbounds i32, i32* %b, i64 %0 - %2 = load i32, i32* %arrayidx3, align 4 - %arrayidx5 = getelementptr inbounds i32, i32* %c, i64 %0 - %3 = load i32, i32* %arrayidx5, align 4 - %cmp6 = icmp eq i32 %2, %3 - %spec.select = select i1 %cmp6, i32 2, i32 4 - br label %if.end - -if.end: ; preds = %land.lhs.true, %for.body - %local_var.0 = phi i32 [ %1, %for.body ], [ %spec.select, %land.lhs.true ] - switch i32 %local_var.0, label %sw.default [ - i32 2, label %sw.bb - i32 4, label %sw.bb7 - i32 5, label %sw.bb8 - i32 7, label %sw.bb9 - ] - -sw.bb: ; preds = %if.end - call void @foo() - br label %sw.bb7 - -sw.bb7: ; preds = %if.end, %sw.bb - call void @bar() - br label %sw.bb8 - -sw.bb8: ; preds = %if.end, %sw.bb7 - call void @baz() - br label %sw.bb9 - -sw.bb9: ; preds = %if.end, %sw.bb8 - call void @quux() - br label %sw.default - -sw.default: ; preds = %if.end, %sw.bb9 - call void @baz() - %inc = add nuw nsw i32 %i.0, 1 - br label %for.cond - -; CHECK-LABEL: @test_func( -; CHECK: [[REG:%[0-9]+]] = load -; CHECK-NOT: select -; CHECK: br i1 -; CHECK-NOT: select -; CHECK: br i1 {{.*}}, label [[DEST1:%.*]], label [[DEST2:%.*]] - -; The following line checks existence of a phi node, and makes sure -; it only has one incoming value. To do this, we check every '%'. Note -; that REG and REG2 each contain one '%;. There is another one in the -; beginning of the incoming block name. After that there should be no other '%'. - -; CHECK: [[REG2:%.*]] = phi i32 {{[^%]*}}[[REG]]{{[^%]*%[^%]*}} -; CHECK: switch i32 [[REG2]] -; CHECK: i32 2, label [[DEST1]] -; CHECK: i32 4, label [[DEST2]] -} diff --git a/llvm/test/Transforms/JumpThreading/static-profile.ll b/llvm/test/Transforms/JumpThreading/static-profile.ll deleted file mode 100644 index 2b2e1cb89cc..00000000000 --- a/llvm/test/Transforms/JumpThreading/static-profile.ll +++ /dev/null @@ -1,128 +0,0 @@ -; RUN: opt -S -jump-threading < %s | FileCheck %s - -; Check that based solely on static profile estimation we don't update the -; branch-weight metadata. Even if the function has an entry frequency, a -; completely cold part of the CFG may be statically estimated. - -; For example in the loop below, jump threading would update the weight of the -; loop-exiting branch to 0, drastically inflating the frequency of the loop -; (in the range of billions). -; -; This is the CFG of the loop. There is no run-time profile info for edges -; inside the loop, so branch and block frequencies are estimated as shown: -; -; check_1 (16) -; (8) / | -; eq_1 | (8) -; \ | -; check_2 (16) -; (8) / | -; eq_2 | (8) -; \ | -; check_3 (16) -; (1) / | -; (loop exit) | (15) -; | -; latch -; | -; (back edge) -; -; First we thread eq_1->check_2 to check_3. Frequencies are updated to remove -; the frequency of eq_1 from check_2 and then the false edge leaving check_2 -; (changed frequencies are highlighted with * *): -; -; check_1 (16) -; (8) / | -; eq_1~ | (8) -; / | -; / check_2 (*8*) -; / (8) / | -; \ eq_2 | (*0*) -; \ \ | -; ` --- check_3 (16) -; (1) / | -; (loop exit) | (15) -; | -; latch -; | -; (back edge) -; -; Next we thread eq_1->check_3 and eq_2->check_3 to check_1 as new edges to -; the loop latch. Frequencies are updated to remove the frequency of eq_1 -; and eq_3 from check_3 and then the false edge leaving check_3 (changed -; frequencies are highlighted with * *): -; -; check_1 (16) -; (8) / | -; eq_1~ | (8) -; / | -; / check_2 (*8*) -; / (8) / | -; /-- eq_2~ | (*0*) -; / | -; / check_3 (*0*) -; / (*0*) / | -; | (loop exit) | (*0*) -; \ | -; `--------- latch -; | -; (back edge) -; -; As a result, the loop exit edge ends up with 0 frequency which in turn makes -; the loop header to have maximum frequency. - -declare void @bar() - -define void @foo(i32 *%p, i32 %n) !prof !0 { -entry: - %enter_loop = icmp eq i32 %n, 0 - br i1 %enter_loop, label %exit, label %check_1, !prof !1 -; CHECK: br i1 %enter_loop, label %exit, label %check_1, !prof !1 - -check_1: - %v = load i32, i32* %p - %cond1 = icmp eq i32 %v, 1 - br i1 %cond1, label %eq_1, label %check_2 -; No metadata: -; CHECK: br i1 %cond1, label %check_2.thread, label %check_2{{$}} - -eq_1: - call void @bar() - br label %check_2 -; Verify the new edge: -; CHECK: check_2.thread: -; CHECK-NEXT: call void @bar() -; CHECK-NEXT: br label %latch - -check_2: - %cond2 = icmp eq i32 %v, 2 - br i1 %cond2, label %eq_2, label %check_3 -; No metadata: -; CHECK: br i1 %cond2, label %eq_2, label %check_3{{$}} - -eq_2: - call void @bar() - br label %check_3 -; Verify the new edge: -; CHECK: eq_2: -; CHECK-NEXT: call void @bar() -; CHECK-NEXT: br label %latch - -check_3: - %condE = icmp eq i32 %v, 3 - br i1 %condE, label %exit, label %latch -; No metadata: -; CHECK: br i1 %condE, label %exit, label %latch{{$}} - -latch: - br label %check_1 - -exit: - ret void -} - -!0 = !{!"function_entry_count", i64 120} -; CHECK-NOT: branch_weights -!1 = !{!"branch_weights", i32 119, i32 1} -; CHECK: !1 = !{!"branch_weights", i32 119, i32 1} -; CHECK-NOT: branch_weights diff --git a/llvm/test/Transforms/JumpThreading/thread-cmp.ll b/llvm/test/Transforms/JumpThreading/thread-cmp.ll deleted file mode 100644 index 95089674476..00000000000 --- a/llvm/test/Transforms/JumpThreading/thread-cmp.ll +++ /dev/null @@ -1,69 +0,0 @@ -; RUN: opt -S -jump-threading %s | FileCheck %s -; When simplify a branch based on LVI predicates, we should replace the -; comparison itself with a constant (when possible) in case it's otherwise used. - -define i32 @test(i32* %p) { -; CHECK-LABEL: @test -; CHECK: icmp eq -; CHECK-NEXT: br i1 %cmp, label %exit2, label %exit1 -; CHECK-NOT: icmp ne -entry: - %cmp = icmp eq i32* %p, null - br i1 %cmp, label %is_null, label %not_null -is_null: - %cmp2 = icmp ne i32* %p, null - br i1 %cmp2, label %exit1, label %exit2 -not_null: - %cmp3 = icmp ne i32* %p, null - br i1 %cmp3, label %exit1, label %exit2 -exit1: - ret i32 0 -exit2: - ret i32 1 -} - -declare void @use(i1) - -; It would not be legal to replace %cmp2 (well, in this case it actually is, -; but that's a CSE problem, not a LVI/jump threading problem) -define i32 @test_negative(i32* %p) { -; CHECK-LABEL: @test -; CHECK: icmp ne -; CHECK: icmp eq -; CHECK-NEXT: br i1 %cmp, label %exit2, label %exit1 -; CHECK-NOT: icmp ne -entry: - %cmp2 = icmp ne i32* %p, null - call void @use(i1 %cmp2) - %cmp = icmp eq i32* %p, null - br i1 %cmp, label %is_null, label %not_null -is_null: - br i1 %cmp2, label %exit1, label %exit2 -not_null: - br i1 %cmp2, label %exit1, label %exit2 -exit1: - ret i32 0 -exit2: - ret i32 1 -} - -; In this case, we can remove cmp2 because it's otherwise unused -define i32 @test2(i32* %p) { -; CHECK-LABEL: @test -; CHECK-LABEL: entry: -; CHECK-NEXT: icmp eq -; CHECK-NEXT: br i1 %cmp, label %exit2, label %exit1 -; CHECK-NOT: icmp ne -entry: - %cmp2 = icmp ne i32* %p, null - %cmp = icmp eq i32* %p, null - br i1 %cmp, label %is_null, label %not_null -is_null: - br i1 %cmp2, label %exit1, label %exit2 -not_null: - br i1 %cmp2, label %exit1, label %exit2 -exit1: - ret i32 0 -exit2: - ret i32 1 -} diff --git a/llvm/test/Transforms/JumpThreading/thread-loads.ll b/llvm/test/Transforms/JumpThreading/thread-loads.ll deleted file mode 100644 index 1156f39d4a2..00000000000 --- a/llvm/test/Transforms/JumpThreading/thread-loads.ll +++ /dev/null @@ -1,542 +0,0 @@ -; RUN: opt < %s -jump-threading -S | FileCheck %s -; RUN: opt < %s -aa-pipeline=basic-aa -passes=jump-threading -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" - -; Test that we can thread through the block with the partially redundant load (%2). -; rdar://6402033 -define i32 @test1(i32* %P) nounwind { -; CHECK-LABEL: @test1( -entry: - %0 = tail call i32 (...) @f1() nounwind ; <i32> [#uses=1] - %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] - br i1 %1, label %bb1, label %bb - -bb: ; preds = %entry -; CHECK: bb1.thread: -; CHECK: store -; CHECK: br label %bb3 - store i32 42, i32* %P, align 4 - br label %bb1 - -bb1: ; preds = %entry, %bb - %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] ; <i32> [#uses=2] - %2 = load i32, i32* %P, align 4 ; <i32> [#uses=1] - %3 = icmp sgt i32 %2, 36 ; <i1> [#uses=1] - br i1 %3, label %bb3, label %bb2 - -bb2: ; preds = %bb1 - %4 = tail call i32 (...) @f2() nounwind ; <i32> [#uses=0] - ret i32 %res.0 - -bb3: ; preds = %bb1 -; CHECK: bb3: -; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ] -; CHECK: ret i32 %res.01 - ret i32 %res.0 -} - -declare i32 @f1(...) - -declare i32 @f2(...) - - -;; Check that we preserve TBAA information. -; rdar://11039258 - -define i32 @test2(i32* %P) nounwind { -; CHECK-LABEL: @test2( -entry: - %0 = tail call i32 (...) @f1() nounwind ; <i32> [#uses=1] - %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] - br i1 %1, label %bb1, label %bb - -bb: ; preds = %entry -; CHECK: bb1.thread: -; CHECK: store{{.*}}, !tbaa !0 -; CHECK: br label %bb3 - store i32 42, i32* %P, align 4, !tbaa !0 - br label %bb1 - -bb1: ; preds = %entry, %bb - %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] - %2 = load i32, i32* %P, align 4, !tbaa !0 - %3 = icmp sgt i32 %2, 36 - br i1 %3, label %bb3, label %bb2 - -bb2: ; preds = %bb1 - %4 = tail call i32 (...) @f2() nounwind - ret i32 %res.0 - -bb3: ; preds = %bb1 -; CHECK: bb3: -; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ] -; CHECK: ret i32 %res.01 - ret i32 %res.0 -} - -define i32 @test3(i8** %x, i1 %f) { -; Correctly thread loads of different (but compatible) types, placing bitcasts -; as necessary in the predecessors. This is especially tricky because the same -; predecessor ends up with two entries in the PHI node and they must share -; a single cast. -; CHECK-LABEL: @test3( -entry: - %0 = bitcast i8** %x to i32** - %1 = load i32*, i32** %0, align 8 - br i1 %f, label %if.end57, label %if.then56 -; CHECK: %[[LOAD:.*]] = load i32*, i32** -; CHECK: %[[CAST:.*]] = bitcast i32* %[[LOAD]] to i8* - -if.then56: - br label %if.end57 - -if.end57: - %2 = load i8*, i8** %x, align 8 - %tobool59 = icmp eq i8* %2, null - br i1 %tobool59, label %return, label %if.then60 -; CHECK: %[[PHI:.*]] = phi i8* [ %[[CAST]], %[[PRED:[^ ]+]] ], [ %[[CAST]], %[[PRED]] ] -; CHECK-NEXT: %[[CMP:.*]] = icmp eq i8* %[[PHI]], null -; CHECK-NEXT: br i1 %[[CMP]] - -if.then60: - ret i32 42 - -return: - ret i32 13 -} - -define i32 @test4(i32* %P) { -; CHECK-LABEL: @test4( -entry: - %v0 = tail call i32 (...) @f1() - %v1 = icmp eq i32 %v0, 0 - br i1 %v1, label %bb1, label %bb - -bb: -; CHECK: bb1.thread: -; CHECK: store atomic -; CHECK: br label %bb3 - store atomic i32 42, i32* %P unordered, align 4 - br label %bb1 - -bb1: -; CHECK: bb1: -; CHECK-NOT: phi -; CHECK: load atomic - %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] - %v2 = load atomic i32, i32* %P unordered, align 4 - %v3 = icmp sgt i32 %v2, 36 - br i1 %v3, label %bb3, label %bb2 - -bb2: - %v4 = tail call i32 (...) @f2() - ret i32 %res.0 - -bb3: - ret i32 %res.0 -} - -define i32 @test5(i32* %P) { -; Negative test - -; CHECK-LABEL: @test5( -entry: - %v0 = tail call i32 (...) @f1() - %v1 = icmp eq i32 %v0, 0 - br i1 %v1, label %bb1, label %bb - -bb: -; CHECK: bb: -; CHECK-NEXT: store atomic i32 42, i32* %P release, align 4 -; CHECK-NEXT: br label %bb1 - store atomic i32 42, i32* %P release, align 4 - br label %bb1 - -bb1: -; CHECK: bb1: -; CHECK-NEXT: %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] -; CHECK-NEXT: %v2 = load atomic i32, i32* %P acquire, align 4 -; CHECK-NEXT: %v3 = icmp sgt i32 %v2, 36 -; CHECK-NEXT: br i1 %v3, label %bb3, label %bb2 - - %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] - %v2 = load atomic i32, i32* %P acquire, align 4 - %v3 = icmp sgt i32 %v2, 36 - br i1 %v3, label %bb3, label %bb2 - -bb2: - %v4 = tail call i32 (...) @f2() - ret i32 %res.0 - -bb3: - ret i32 %res.0 -} - -define i32 @test6(i32* %P) { -; Negative test - -; CHECK-LABEL: @test6( -entry: - %v0 = tail call i32 (...) @f1() - %v1 = icmp eq i32 %v0, 0 - br i1 %v1, label %bb1, label %bb - -bb: -; CHECK: bb: -; CHECK-NEXT: store i32 42, i32* %P -; CHECK-NEXT: br label %bb1 - store i32 42, i32* %P - br label %bb1 - -bb1: -; CHECK: bb1: -; CHECK-NEXT: %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] -; CHECK-NEXT: %v2 = load atomic i32, i32* %P acquire, align 4 -; CHECK-NEXT: %v3 = icmp sgt i32 %v2, 36 -; CHECK-NEXT: br i1 %v3, label %bb3, label %bb2 - - %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] - %v2 = load atomic i32, i32* %P acquire, align 4 - %v3 = icmp sgt i32 %v2, 36 - br i1 %v3, label %bb3, label %bb2 - -bb2: - %v4 = tail call i32 (...) @f2() - ret i32 %res.0 - -bb3: - ret i32 %res.0 -} - -define i32 @test7(i32* %P) { -; Negative test - -; CHECK-LABEL: @test7( -entry: - %v0 = tail call i32 (...) @f1() - %v1 = icmp eq i32 %v0, 0 - br i1 %v1, label %bb1, label %bb - -bb: -; CHECK: bb: -; CHECK-NEXT: %val = load i32, i32* %P -; CHECK-NEXT: br label %bb1 - %val = load i32, i32* %P - br label %bb1 - -bb1: -; CHECK: bb1: -; CHECK-NEXT: %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] -; CHECK-NEXT: %v2 = load atomic i32, i32* %P acquire, align 4 -; CHECK-NEXT: %v3 = icmp sgt i32 %v2, 36 -; CHECK-NEXT: br i1 %v3, label %bb3, label %bb2 - - %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] - %v2 = load atomic i32, i32* %P acquire, align 4 - %v3 = icmp sgt i32 %v2, 36 - br i1 %v3, label %bb3, label %bb2 - -bb2: - %v4 = tail call i32 (...) @f2() - ret i32 %res.0 - -bb3: - ret i32 %res.0 -} - -; Make sure we merge the aliasing metadata. We keep the range metadata for the -; first load, as it dominates the second load. Hence we can eliminate the -; branch. -define void @test8(i32*, i32*, i32*) { -; CHECK-LABEL: @test8( -; CHECK: %a = load i32, i32* %0, !range ![[RANGE4:[0-9]+]] -; CHECK-NEXT: store i32 %a -; CHECK-NEXT: %xxx = tail call i32 (...) @f1() -; CHECK-NEXT: ret void - %a = load i32, i32* %0, !tbaa !0, !range !4, !alias.scope !9, !noalias !10 - %b = load i32, i32* %0, !range !5 - store i32 %a, i32* %1 - %c = icmp eq i32 %b, 8 - br i1 %c, label %ret1, label %ret2 - -ret1: - ret void - -ret2: - %xxx = tail call i32 (...) @f1() nounwind - ret void -} - -; Make sure we merge/PRE aliasing metadata correctly. That means that -; we need to remove metadata from the existing load, and add appropriate -; metadata to the newly inserted load. -define void @test9(i32*, i32*, i32*, i1 %c) { -; CHECK-LABEL: @test9( - br i1 %c, label %d1, label %d2 - -; CHECK: d1: -; CHECK-NEXT: %a = load i32, i32* %0{{$}} -d1: - %a = load i32, i32* %0, !range !4, !alias.scope !9, !noalias !10 - br label %d3 - -; CHECK: d2: -; CHECK-NEXT: %xxxx = tail call i32 (...) @f1() -; CHECK-NEXT: %b.pr = load i32, i32* %0, !tbaa !0{{$}} -d2: - %xxxx = tail call i32 (...) @f1() nounwind - br label %d3 - -d3: - %p = phi i32 [ 1, %d2 ], [ %a, %d1 ] - %b = load i32, i32* %0, !tbaa !0 - store i32 %p, i32* %1 - %c2 = icmp eq i32 %b, 8 - br i1 %c2, label %ret1, label %ret2 - -ret1: - ret void - -ret2: - %xxx = tail call i32 (...) @f1() nounwind - ret void -} - -define i32 @fn_noalias(i1 %c2,i64* noalias %P, i64* noalias %P2) { -; CHECK-LABEL: @fn_noalias -; CHECK-LABEL: cond1: -; CHECK: %[[LD1:.*]] = load i64, i64* %P -; CHECK: br i1 %c, label %[[THREAD:.*]], label %end -; CHECK-LABEL: cond2: -; CHECK: %[[LD2:.*]] = load i64, i64* %P -; CHECK-LABEL: cond3: -; CHECK: %[[PHI:.*]] = phi i64 [ %[[LD1]], %[[THREAD]] ], [ %[[LD2]], %cond2 ] -; CHECK: call void @fn3(i64 %[[PHI]]) -entry: - br i1 %c2, label %cond2, label %cond1 - -cond1: - %l1 = load i64, i64* %P - store i64 42, i64* %P2 - %c = icmp eq i64 %l1, 0 - br i1 %c, label %cond2, label %end - -cond2: - %l2 = load i64, i64* %P - call void @fn2(i64 %l2) - %c3 = icmp eq i64 %l2, 0 - br i1 %c3, label %cond3, label %end - -cond3: - call void @fn3(i64 %l2) - br label %end - -end: - ret i32 0 -} - -; This tests if we can thread from %sw.bb.i to %do.body.preheader.i67 through -; %sw.bb21.i. To make this happen, %l2 should be detected as a partically -; redundant load with %l3 across the store to %phase in %sw.bb21.i. - -%struct.NEXT_MOVE = type { i32, i32, i32* } -@hash_move = unnamed_addr global [65 x i32] zeroinitializer, align 4 -@current_move = internal global [65 x i32] zeroinitializer, align 4 -@last = internal unnamed_addr global [65 x i32*] zeroinitializer, align 8 -@next_status = internal unnamed_addr global [65 x %struct.NEXT_MOVE] zeroinitializer, align 8 -define fastcc i32 @Search(i64 %idxprom.i, i64 %idxprom.i89, i32 %c) { -; CHECK-LABEL: @Search -; CHECK-LABEL: sw.bb.i: -; CHECK: %[[LD1:.*]] = load i32, i32* %arrayidx185, align 4 -; CHECK: %[[C1:.*]] = icmp eq i32 %[[LD1]], 0 -; CHECK: br i1 %[[C1]], label %sw.bb21.i.thread, label %if.then.i64 -; CHECK-LABEL: sw.bb21.i.thread: -; CHECK: br label %[[THREAD_TO:.*]] -; CHECK-LABEL: sw.bb21.i: -; CHECK: %[[LD2:.*]] = load i32, i32* %arrayidx185, align 4 -; CHECK: %[[C2:.*]] = icmp eq i32 %[[LD2]], 0 -; CHECK:br i1 %[[C2]], label %[[THREAD_TO]], label %cleanup -entry: - %arrayidx185 = getelementptr inbounds [65 x i32], [65 x i32]* @hash_move, i64 0, i64 %idxprom.i - %arrayidx307 = getelementptr inbounds [65 x i32], [65 x i32]* @current_move, i64 0, i64 %idxprom.i - %arrayidx89 = getelementptr inbounds [65 x i32*], [65 x i32*]* @last, i64 0, i64 %idxprom.i - %phase = getelementptr inbounds [65 x %struct.NEXT_MOVE], [65 x %struct.NEXT_MOVE]* @next_status, i64 0, i64 %idxprom.i, i32 0 - br label %cond.true282 - -cond.true282: - switch i32 %c, label %sw.default.i [ - i32 1, label %sw.bb.i - i32 0, label %sw.bb21.i - ] - -sw.default.i: - br label %cleanup - -sw.bb.i: - %call.i62 = call fastcc i32* @GenerateCheckEvasions() - store i32* %call.i62, i32** %arrayidx89, align 8 - %l2 = load i32, i32* %arrayidx185, align 4 - %tobool.i63 = icmp eq i32 %l2, 0 - br i1 %tobool.i63, label %sw.bb21.i, label %if.then.i64 - -if.then.i64: ; preds = %sw.bb.i - store i32 7, i32* %phase, align 8 - store i32 %l2, i32* %arrayidx307, align 4 - %call16.i = call fastcc i32 @ValidMove(i32 %l2) - %tobool17.i = icmp eq i32 %call16.i, 0 - br i1 %tobool17.i, label %if.else.i65, label %cleanup - -if.else.i65: - call void @f65() - br label %sw.bb21.i - -sw.bb21.i: - store i32 10, i32* %phase, align 8 - %l3= load i32, i32* %arrayidx185, align 4 - %tobool27.i = icmp eq i32 %l3, 0 - br i1 %tobool27.i, label %do.body.preheader.i67, label %cleanup - -do.body.preheader.i67: - call void @f67() - ret i32 67 - -cleanup: - call void @Cleanup() - ret i32 0 -} - -declare fastcc i32* @GenerateCheckEvasions() -declare fastcc i32 @ValidMove(i32 %move) -declare void @f67() -declare void @Cleanup() -declare void @f65() - -define i32 @fn_SinglePred(i1 %c2,i64* %P) { -; CHECK-LABEL: @fn_SinglePred -; CHECK-LABEL: entry: -; CHECK: %[[L1:.*]] = load i64, i64* %P -; CHECK: br i1 %c, label %cond3, label %cond1 -; CHECK-LABEL: cond2: -; CHECK-NOT: load -; CHECK: %[[PHI:.*]] = phi i64 [ %[[L1]], %cond1 ] -; CHECK: call void @fn2(i64 %[[PHI]]) -; CHECK: br label %end -; CHECK-LABEL: cond3: -; CHECK: call void @fn2(i64 %l1) -; CHECK: call void @fn3(i64 %l1) - -entry: - %l1 = load i64, i64* %P - %c = icmp eq i64 %l1, 0 - br i1 %c, label %cond2, label %cond1 - -cond1: - br i1 %c2, label %cond2, label %end - -cond2: - %l2 = load i64, i64* %P - call void @fn2(i64 %l2) - %c3 = icmp eq i64 %l2, 0 - br i1 %c3, label %cond3, label %end - -cond3: - call void @fn3(i64 %l2) - br label %end - -end: - ret i32 0 -} - -define i32 @fn_SinglePredMultihop(i1 %c1, i1 %c2,i64* %P) { -; CHECK-LABEL: @fn_SinglePredMultihop -; CHECK-LABEL: entry: -; CHECK: %[[L1:.*]] = load i64, i64* %P -; CHECK: br i1 %c0, label %cond3, label %cond0 -; CHECK-LABEL: cond2: -; CHECK-NOT: load -; CHECK: %[[PHI:.*]] = phi i64 [ %[[L1]], %cond1 ] -; CHECK: call void @fn2(i64 %[[PHI]]) -; CHECK: br label %end -; CHECK-LABEL: cond3: -; CHECK: call void @fn2(i64 %l1) -; CHECK: call void @fn3(i64 %l1) - -entry: - %l1 = load i64, i64* %P - %c0 = icmp eq i64 %l1, 0 - br i1 %c0, label %cond2, label %cond0 - -cond0: - br i1 %c1, label %cond1, label %end - -cond1: - br i1 %c2, label %cond2, label %end - -cond2: - %l2 = load i64, i64* %P - call void @fn2(i64 %l2) - %c3 = icmp eq i64 %l2, 0 - br i1 %c3, label %cond3, label %end - -cond3: - call void @fn3(i64 %l2) - br label %end - -end: - ret i32 0 -} - -declare void @fn2(i64) -declare void @fn3(i64) - - -; Make sure we phi-translate and make the partially redundant load in -; merge fully redudant and then we can jump-thread the block with the -; store. -; -; CHECK-LABEL: define i32 @phi_translate_partial_redundant_loads(i32, i32*, i32* -; CHECK: merge.thread: -; CHECK: store -; CHECK: br label %left_x -; -; CHECK: left_x: -; CHECK-NEXT: ret i32 20 -define i32 @phi_translate_partial_redundant_loads(i32, i32*, i32*) { - %cmp0 = icmp ne i32 %0, 0 - br i1 %cmp0, label %left, label %right - -left: - store i32 1, i32* %1, align 4 - br label %merge - -right: - br label %merge - -merge: - %phiptr = phi i32* [ %1, %left ], [ %2, %right ] - %newload = load i32, i32* %phiptr, align 4 - %cmp1 = icmp slt i32 %newload, 5 - br i1 %cmp1, label %left_x, label %right_x - -left_x: - ret i32 20 - -right_x: - ret i32 10 -} - -; CHECK: ![[RANGE4]] = !{i32 0, i32 1} - -!0 = !{!3, !3, i64 0} -!1 = !{!"omnipotent char", !2} -!2 = !{!"Simple C/C++ TBAA"} -!3 = !{!"int", !1} -!4 = !{ i32 0, i32 1 } -!5 = !{ i32 8, i32 10 } -!6 = !{!6} -!7 = !{!7, !6} -!8 = !{!8, !6} -!9 = !{!7} -!10 = !{!8} diff --git a/llvm/test/Transforms/JumpThreading/threading_prof1.ll b/llvm/test/Transforms/JumpThreading/threading_prof1.ll deleted file mode 100644 index 1bfd4509714..00000000000 --- a/llvm/test/Transforms/JumpThreading/threading_prof1.ll +++ /dev/null @@ -1,99 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s -; RUN: opt -passes=jump-threading -S < %s | FileCheck %s - -define void @test() { -; CHECK-LABEL: @test() -bb: - %tmp = call i32 @a() - %tmp1 = icmp eq i32 %tmp, 1 - br i1 %tmp1, label %bb5, label %bb2 -; CHECK: br i1 %tmp1,{{.*}} !prof ![[PROF1:[0-9]+]] - -bb2: ; preds = %bb - %tmp3 = call i32 @b() - %tmp4 = icmp ne i32 %tmp3, 1 - br label %bb5 -; CHECK: br i1 %tmp4, {{.*}} !prof ![[PROF2:[0-9]+]] - -bb5: ; preds = %bb2, %bb - %tmp6 = phi i1 [ false, %bb ], [ %tmp4, %bb2 ] - br i1 %tmp6, label %bb8, label %bb7, !prof !0 - -bb7: ; preds = %bb5 - call void @bar() - br label %bb8 - -bb8: ; preds = %bb7, %bb5 - ret void -} - -define void @test_single_pred1() { -; CHECK-LABEL: @test_single_pred1() -bb: - %tmp = call i32 @a() - %tmp1 = icmp eq i32 %tmp, 1 - br i1 %tmp1, label %bb5_1, label %bb2 -; CHECK: br i1 %tmp1,{{.*}} !prof ![[PROF1:[0-9]+]] - -bb5_1: - br label %bb5; - -bb2: - %tmp3 = call i32 @b() - %tmp4 = icmp ne i32 %tmp3, 1 - br label %bb5 -; CHECK: br i1 %tmp4, {{.*}} !prof ![[PROF2:[0-9]+]] - -bb5: - %tmp6 = phi i1 [ false, %bb5_1 ], [ %tmp4, %bb2 ] - br i1 %tmp6, label %bb8, label %bb7, !prof !0 - -bb7: - call void @bar() - br label %bb8 - -bb8: - ret void -} - -define void @test_single_pred2() { -; CHECK-LABEL: @test_single_pred2() -bb: - %tmp = call i32 @a() - %tmp1 = icmp eq i32 %tmp, 1 - br i1 %tmp1, label %bb5_1, label %bb2 -; CHECK: br i1 %tmp1,{{.*}} !prof ![[PROF1:[0-9]+]] - -bb5_1: - br label %bb5_2; - -bb5_2: - br label %bb5; - -bb2: - %tmp3 = call i32 @b() - %tmp4 = icmp ne i32 %tmp3, 1 - br label %bb5 -; CHECK: br i1 %tmp4, {{.*}} !prof ![[PROF2:[0-9]+]] - -bb5: - %tmp6 = phi i1 [ false, %bb5_2 ], [ %tmp4, %bb2 ] - br i1 %tmp6, label %bb8, label %bb7, !prof !0 - -bb7: - call void @bar() - br label %bb8 - -bb8: - ret void -} - -declare void @bar() - -declare i32 @a() - -declare i32 @b() - -!0 = !{!"branch_weights", i32 2146410443, i32 1073205} -;CHECK: ![[PROF1]] = !{!"branch_weights", i32 1073205, i32 2146410443} -;CHECK: ![[PROF2]] = !{!"branch_weights", i32 2146410443, i32 1073205} diff --git a/llvm/test/Transforms/JumpThreading/threading_prof2.ll b/llvm/test/Transforms/JumpThreading/threading_prof2.ll deleted file mode 100644 index b14b996f24e..00000000000 --- a/llvm/test/Transforms/JumpThreading/threading_prof2.ll +++ /dev/null @@ -1,42 +0,0 @@ -; RUN: opt -jump-threading -S < %s | FileCheck %s -; RUN: opt -passes=jump-threading -S < %s | FileCheck %s -define void @test() { -bb: - %tmp = call i32 @a() - %tmp1 = icmp eq i32 %tmp, 1 - br i1 %tmp1, label %bb5, label %bb2 -; CHECK: br i1 %tmp1,{{.*}} !prof ![[PROF1:[0-9]+]] - -bb2: - %tmp3 = call i32 @b() - %tmp4 = icmp ne i32 %tmp3, 1 - br label %bb5 -; CHECK: br i1 %tmp4, {{.*}} !prof ![[PROF2:[0-9]+]] - -bb5: - %tmp6 = phi i1 [ false, %bb ], [ %tmp4, %bb2 ] - br i1 %tmp6, label %bb8, label %bb7, !prof !0 - -bb7: - call void @bar() - br label %bb9 - -bb8: - call void @foo() - br label %bb9 - -bb9: - ret void -} - -declare void @bar() - -declare void @foo() - -declare i32 @a() - -declare i32 @b() - -!0 = !{!"branch_weights", i32 2146410443, i32 1073205} -;CHECK: ![[PROF1]] = !{!"branch_weights", i32 1073205, i32 2146410443} -;CHECK: ![[PROF2]] = !{!"branch_weights", i32 2146410443, i32 1073205} diff --git a/llvm/test/Transforms/JumpThreading/update-edge-weight.ll b/llvm/test/Transforms/JumpThreading/update-edge-weight.ll deleted file mode 100644 index 58cd71861d8..00000000000 --- a/llvm/test/Transforms/JumpThreading/update-edge-weight.ll +++ /dev/null @@ -1,43 +0,0 @@ -; RUN: opt -S -jump-threading %s | FileCheck %s - -; Test if edge weights are properly updated after jump threading. - -; CHECK: !2 = !{!"branch_weights", i32 1629125526, i32 518358122} - -define void @foo(i32 %n) !prof !0 { -entry: - %cmp = icmp sgt i32 %n, 10 - br i1 %cmp, label %if.then.1, label %if.else.1, !prof !1 - -if.then.1: - tail call void @a() - br label %if.cond - -if.else.1: - tail call void @b() - br label %if.cond - -if.cond: - %cmp1 = icmp sgt i32 %n, 5 - br i1 %cmp1, label %if.then.2, label %if.else.2, !prof !2 - -if.then.2: - tail call void @c() - br label %if.end - -if.else.2: - tail call void @d() - br label %if.end - -if.end: - ret void -} - -declare void @a() -declare void @b() -declare void @c() -declare void @d() - -!0 = !{!"function_entry_count", i64 1} -!1 = !{!"branch_weights", i32 10, i32 5} -!2 = !{!"branch_weights", i32 10, i32 1} |