diff options
Diffstat (limited to 'test/Analysis')
110 files changed, 2088 insertions, 1050 deletions
diff --git a/test/Analysis/BasicAA/full-store-partial-alias.ll b/test/Analysis/BasicAA/full-store-partial-alias.ll index 2c34fd5f615a5..4de2daf6b2dc7 100644 --- a/test/Analysis/BasicAA/full-store-partial-alias.ll +++ b/test/Analysis/BasicAA/full-store-partial-alias.ll @@ -29,7 +29,9 @@ entry: ret i32 %tmp5.lobit } -!0 = metadata !{metadata !"double", metadata !1} +!0 = metadata !{metadata !4, metadata !4, i64 0} !1 = metadata !{metadata !"omnipotent char", metadata !2} !2 = metadata !{metadata !"Simple C/C++ TBAA", null} -!3 = metadata !{metadata !"int", metadata !1} +!3 = metadata !{metadata !5, metadata !5, i64 0} +!4 = metadata !{metadata !"double", metadata !1} +!5 = metadata !{metadata !"int", metadata !1} diff --git a/test/Analysis/BasicAA/gep-alias.ll b/test/Analysis/BasicAA/gep-alias.ll index 9c2c7eeec38d5..2c0d467003f28 100644 --- a/test/Analysis/BasicAA/gep-alias.ll +++ b/test/Analysis/BasicAA/gep-alias.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -basicaa -gvn -instcombine -S 2>&1 | 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 datalayout = "e-p:32:32:32-p1:16:16:16-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" ; Make sure that basicaa thinks R and r are must aliases. define i32 @test1(i8 * %P) { @@ -15,7 +15,7 @@ entry: %t = sub i32 %S, %s ret i32 %t -; CHECK: @test1 +; CHECK-LABEL: @test1( ; CHECK: ret i32 0 } @@ -32,7 +32,7 @@ entry: %t = sub i32 %S, %s ret i32 %t -; CHECK: @test2 +; CHECK-LABEL: @test2( ; CHECK: ret i32 0 } @@ -51,7 +51,7 @@ entry: %t = sub i32 %S, %s ret i32 %t -; CHECK: @test3 +; CHECK-LABEL: @test3( ; CHECK: ret i32 0 } @@ -68,7 +68,7 @@ entry: store i8* null, i8** %tmp3, align 8 %tmp4 = load i32* %tmp2, align 8 ret i32 %tmp4 -; CHECK: @test4 +; CHECK-LABEL: @test4( ; CHECK: ret i32 64 } @@ -82,7 +82,34 @@ define i32 @test5(i32* %p, i64 %i) { %y = load i32* %pi %z = sub i32 %x, %y ret i32 %z -; CHECK: @test5 +; CHECK-LABEL: @test5( +; CHECK: ret i32 0 +} + +define i32 @test5_as1_smaller_size(i32 addrspace(1)* %p, i8 %i) { + %pi = getelementptr i32 addrspace(1)* %p, i8 %i + %i.next = add i8 %i, 1 + %pi.next = getelementptr i32 addrspace(1)* %p, i8 %i.next + %x = load i32 addrspace(1)* %pi + store i32 42, i32 addrspace(1)* %pi.next + %y = load i32 addrspace(1)* %pi + %z = sub i32 %x, %y + ret i32 %z +; CHECK-LABEL: @test5_as1_smaller_size( +; CHECK: sext +; CHECK: ret i32 0 +} + +define i32 @test5_as1_same_size(i32 addrspace(1)* %p, i16 %i) { + %pi = getelementptr i32 addrspace(1)* %p, i16 %i + %i.next = add i16 %i, 1 + %pi.next = getelementptr i32 addrspace(1)* %p, i16 %i.next + %x = load i32 addrspace(1)* %pi + store i32 42, i32 addrspace(1)* %pi.next + %y = load i32 addrspace(1)* %pi + %z = sub i32 %x, %y + ret i32 %z +; CHECK-LABEL: @test5_as1_same_size( ; CHECK: ret i32 0 } @@ -97,7 +124,7 @@ define i32 @test6(i32* %p, i64 %i1) { %y = load i32* %pi %z = sub i32 %x, %y ret i32 %z -; CHECK: @test6 +; CHECK-LABEL: @test6( ; CHECK: ret i32 0 } @@ -111,7 +138,7 @@ define i32 @test7(i32* %p, i64 %i) { %y = load i32* %pi %z = sub i32 %x, %y ret i32 %z -; CHECK: @test7 +; CHECK-LABEL: @test7( ; CHECK: ret i32 0 } @@ -128,7 +155,7 @@ define i32 @test8(i32* %p, i16 %i) { %y = load i32* %pi %z = sub i32 %x, %y ret i32 %z -; CHECK: @test8 +; CHECK-LABEL: @test8( ; CHECK: ret i32 0 } @@ -139,7 +166,7 @@ define i8 @test9([4 x i8] *%P, i32 %i, i32 %j) { %P2 = getelementptr [4 x i8] *%P, i32 0, i32 %i3 %j2 = shl i32 %j, 2 - + ; P4 = P + 4*j %P4 = getelementptr [4 x i8]* %P, i32 0, i32 %j2 @@ -148,7 +175,7 @@ define i8 @test9([4 x i8] *%P, i32 %i, i32 %j) { %y = load i8* %P2 %z = sub i8 %x, %y ret i8 %z -; CHECK: @test9 +; CHECK-LABEL: @test9( ; CHECK: ret i8 0 } @@ -157,7 +184,7 @@ define i8 @test10([4 x i8] *%P, i32 %i) { %i3 = add i32 %i2, 4 ; P2 = P + 4 + 4*i %P2 = getelementptr [4 x i8] *%P, i32 0, i32 %i3 - + ; P4 = P + 4*i %P4 = getelementptr [4 x i8]* %P, i32 0, i32 %i2 @@ -166,7 +193,7 @@ define i8 @test10([4 x i8] *%P, i32 %i) { %y = load i8* %P2 %z = sub i8 %x, %y ret i8 %z -; CHECK: @test10 +; CHECK-LABEL: @test10( ; CHECK: ret i8 0 } @@ -182,8 +209,8 @@ define float @test11(i32 %indvar, [4 x [2 x float]]* %q) nounwind ssp { store i64 0, i64* %scevgep35, align 4 %tmp30 = load float* %y29, align 4 ret float %tmp30 - ; CHECK: @test11 - ; CHECK: ret float %tmp30 +; CHECK-LABEL: @test11( +; CHECK: ret float %tmp30 } ; (This was a miscompilation.) @@ -198,6 +225,6 @@ define i32 @test12(i32 %x, i32 %y, i8* %p) nounwind { store i32 0, i32* %castd %r = load i32* %castp ret i32 %r - ; CHECK: @test12 - ; CHECK: ret i32 %r +; CHECK-LABEL: @test12( +; CHECK: ret i32 %r } diff --git a/test/Analysis/BasicAA/global-size.ll b/test/Analysis/BasicAA/global-size.ll index a7e5aab6c1f22..f081cb1e07246 100644 --- a/test/Analysis/BasicAA/global-size.ll +++ b/test/Analysis/BasicAA/global-size.ll @@ -2,11 +2,11 @@ ; the global. ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +target datalayout = "E-p:64:64:64-p1:16:16:16-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @B = global i16 8 -; CHECK: @test1 +; CHECK-LABEL: @test1( define i16 @test1(i32* %P) { %X = load i16* @B store i32 7, i32* %P @@ -16,11 +16,23 @@ define i16 @test1(i32* %P) { ; CHECK: ret i16 0 } +@B_as1 = addrspace(1) global i16 8 + +define i16 @test1_as1(i32 addrspace(1)* %P) { +; CHECK-LABEL: @test1_as1( +; CHECK: ret i16 0 + %X = load i16 addrspace(1)* @B_as1 + store i32 7, i32 addrspace(1)* %P + %Y = load i16 addrspace(1)* @B_as1 + %Z = sub i16 %Y, %X + ret i16 %Z +} + ; Cannot know anything about the size of this global. ; rdar://8813415 @window = external global [0 x i8] -; CHECK: @test2 +; CHECK-LABEL: @test2( define i8 @test2(i32 %tmp79, i32 %w.2, i32 %indvar89) nounwind { %tmp92 = add i32 %tmp79, %indvar89 %arrayidx412 = getelementptr [0 x i8]* @window, i32 0, i32 %tmp92 diff --git a/test/Analysis/BasicAA/noalias-geps.ll b/test/Analysis/BasicAA/noalias-geps.ll index a93d778da0741..f9ec71345739e 100644 --- a/test/Analysis/BasicAA/noalias-geps.ll +++ b/test/Analysis/BasicAA/noalias-geps.ll @@ -4,6 +4,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3 ; Check that geps with equal base offsets of noalias base pointers stay noalias. define i32 @test(i32* %p, i16 %i) { +; CHECK-LABEL: Function: test: %pi = getelementptr i32* %p, i32 0 %pi.next = getelementptr i32* %p, i32 1 %b = icmp eq i16 %i, 0 @@ -30,6 +31,7 @@ ret i32 0 ; Check that geps with equal indices of noalias base pointers stay noalias. define i32 @test2([2 x i32]* %p, i32 %i) { +; CHECK-LABEL: Function: test2: %pi = getelementptr [2 x i32]* %p, i32 0 %pi.next = getelementptr [2 x i32]* %p, i32 1 %b = icmp eq i32 %i, 0 diff --git a/test/Analysis/BasicAA/noalias-param.ll b/test/Analysis/BasicAA/noalias-param.ll new file mode 100644 index 0000000000000..6494771fc59f7 --- /dev/null +++ b/test/Analysis/BasicAA/noalias-param.ll @@ -0,0 +1,23 @@ +; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s + +declare i32* @captures(i32* %cap) nounwind readonly + +define void @no(i32* noalias %a, i32* %b) nounwind { +entry: + store i32 1, i32* %a + %cap = call i32* @captures(i32* %a) nounwind readonly + %l = load i32* %b + ret void +} + +; CHECK: NoAlias: i32* %a, i32* %b + +define void @yes(i32* %c, i32* %d) nounwind { +entry: + store i32 1, i32* %c + %cap = call i32* @captures(i32* %c) nounwind readonly + %l = load i32* %d + ret void +} + +; CHECK: MayAlias: i32* %c, i32* %d diff --git a/test/Analysis/BlockFrequencyInfo/basic.ll b/test/Analysis/BlockFrequencyInfo/basic.ll index 540d06b1f5627..ce29fb5ce1ba8 100644 --- a/test/Analysis/BlockFrequencyInfo/basic.ll +++ b/test/Analysis/BlockFrequencyInfo/basic.ll @@ -2,12 +2,12 @@ define i32 @test1(i32 %i, i32* %a) { ; CHECK: Printing analysis {{.*}} for function 'test1' -; CHECK: entry = 1024 +; CHECK: entry = 1.0 entry: br label %body ; Loop backedges are weighted and thus their bodies have a greater frequency. -; CHECK: body = 31744 +; CHECK: body = 32.0 body: %iv = phi i32 [ 0, %entry ], [ %next, %body ] %base = phi i32 [ 0, %entry ], [ %sum, %body ] @@ -18,29 +18,29 @@ body: %exitcond = icmp eq i32 %next, %i br i1 %exitcond, label %exit, label %body -; CHECK: exit = 1024 +; CHECK: exit = 1.0 exit: ret i32 %sum } define i32 @test2(i32 %i, i32 %a, i32 %b) { ; CHECK: Printing analysis {{.*}} for function 'test2' -; CHECK: entry = 1024 +; CHECK: entry = 1.0 entry: %cond = icmp ult i32 %i, 42 br i1 %cond, label %then, label %else, !prof !0 ; The 'then' branch is predicted more likely via branch weight metadata. -; CHECK: then = 963 +; CHECK: then = 0.94116 then: br label %exit -; CHECK: else = 60 +; CHECK: else = 0.05877 else: br label %exit -; FIXME: It may be a bug that we don't sum back to 1024. -; CHECK: exit = 1023 +; FIXME: It may be a bug that we don't sum back to 1.0. +; CHECK: exit = 0.99993 exit: %result = phi i32 [ %a, %then ], [ %b, %else ] ret i32 %result @@ -50,36 +50,36 @@ exit: define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { ; CHECK: Printing analysis {{.*}} for function 'test3' -; CHECK: entry = 1024 +; CHECK: entry = 1.0 entry: switch i32 %i, label %case_a [ i32 1, label %case_b i32 2, label %case_c i32 3, label %case_d i32 4, label %case_e ], !prof !1 -; CHECK: case_a = 51 +; CHECK: case_a = 0.04998 case_a: br label %exit -; CHECK: case_b = 51 +; CHECK: case_b = 0.04998 case_b: br label %exit ; The 'case_c' branch is predicted more likely via branch weight metadata. -; CHECK: case_c = 819 +; CHECK: case_c = 0.79998 case_c: br label %exit -; CHECK: case_d = 51 +; CHECK: case_d = 0.04998 case_d: br label %exit -; CHECK: case_e = 51 +; CHECK: case_e = 0.04998 case_e: br label %exit -; FIXME: It may be a bug that we don't sum back to 1024. -; CHECK: exit = 1023 +; FIXME: It may be a bug that we don't sum back to 1.0. +; CHECK: exit = 0.99993 exit: %result = phi i32 [ %a, %case_a ], [ %b, %case_b ], @@ -90,3 +90,45 @@ exit: } !1 = metadata !{metadata !"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4} + +; CHECK: Printing analysis {{.*}} for function 'nested_loops' +; CHECK: entry = 1.0 +; This test doesn't seem to be assigning sensible frequencies to nested loops. +define void @nested_loops(i32 %a) { +entry: + br label %for.cond1.preheader + +for.cond1.preheader: + %x.024 = phi i32 [ 0, %entry ], [ %inc12, %for.inc11 ] + br label %for.cond4.preheader + +for.cond4.preheader: + %y.023 = phi i32 [ 0, %for.cond1.preheader ], [ %inc9, %for.inc8 ] + %add = add i32 %y.023, %x.024 + br label %for.body6 + +for.body6: + %z.022 = phi i32 [ 0, %for.cond4.preheader ], [ %inc, %for.body6 ] + %add7 = add i32 %add, %z.022 + tail call void @g(i32 %add7) #2 + %inc = add i32 %z.022, 1 + %cmp5 = icmp ugt i32 %inc, %a + br i1 %cmp5, label %for.inc8, label %for.body6, !prof !2 + +for.inc8: + %inc9 = add i32 %y.023, 1 + %cmp2 = icmp ugt i32 %inc9, %a + br i1 %cmp2, label %for.inc11, label %for.cond4.preheader, !prof !2 + +for.inc11: + %inc12 = add i32 %x.024, 1 + %cmp = icmp ugt i32 %inc12, %a + br i1 %cmp, label %for.end13, label %for.cond1.preheader, !prof !2 + +for.end13: + ret void +} + +declare void @g(i32) #1 + +!2 = metadata !{metadata !"branch_weights", i32 1, i32 4000} diff --git a/test/Analysis/BlockFrequencyInfo/lit.local.cfg b/test/Analysis/BlockFrequencyInfo/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/BlockFrequencyInfo/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/BranchProbabilityInfo/basic.ll b/test/Analysis/BranchProbabilityInfo/basic.ll index 08adfa8a36fb0..05cb31dca0ee9 100644 --- a/test/Analysis/BranchProbabilityInfo/basic.ll +++ b/test/Analysis/BranchProbabilityInfo/basic.ll @@ -115,3 +115,100 @@ return: } !2 = metadata !{metadata !"branch_weights", i32 7, i32 6, i32 4, i32 4, i32 64} + +declare void @coldfunc() cold + +define i32 @test5(i32 %a, i32 %b, i1 %flag) { +; CHECK: Printing analysis {{.*}} for function 'test5' +entry: + br i1 %flag, label %then, label %else +; CHECK: edge entry -> then probability is 4 / 68 +; CHECK: edge entry -> else probability is 64 / 68 + +then: + call void @coldfunc() + br label %exit +; CHECK: edge then -> exit probability is 16 / 16 = 100% + +else: + br label %exit +; CHECK: edge else -> exit probability is 16 / 16 = 100% + +exit: + %result = phi i32 [ %a, %then ], [ %b, %else ] + ret i32 %result +} + +declare i32 @regular_function(i32 %i) + +define i32 @test_cold_call_sites(i32* %a) { +; Test that edges to blocks post-dominated by cold call sites +; are marked as not expected to be taken. +; TODO(dnovillo) The calls to regular_function should not be merged, but +; they are currently being merged. Convert this into a code generation test +; after that is fixed. + +; CHECK: Printing analysis {{.*}} for function 'test_cold_call_sites' +; CHECK: edge entry -> then probability is 4 / 68 = 5.88235% +; CHECK: edge entry -> else probability is 64 / 68 = 94.1176% [HOT edge] + +entry: + %gep1 = getelementptr i32* %a, i32 1 + %val1 = load i32* %gep1 + %cond1 = icmp ugt i32 %val1, 1 + br i1 %cond1, label %then, label %else + +then: + ; This function is not declared cold, but this call site is. + %val4 = call i32 @regular_function(i32 %val1) cold + br label %exit + +else: + %gep2 = getelementptr i32* %a, i32 2 + %val2 = load i32* %gep2 + %val3 = call i32 @regular_function(i32 %val2) + br label %exit + +exit: + %ret = phi i32 [ %val4, %then ], [ %val3, %else ] + ret i32 %ret +} + +define i32 @zero1(i32 %i, i32 %a, i32 %b) { +; CHECK: Printing analysis {{.*}} for function 'zero1' +entry: + %cond = icmp eq i32 %i, 0 + br i1 %cond, label %then, label %else +; CHECK: edge entry -> then probability is 12 / 32 +; CHECK: edge entry -> else probability is 20 / 32 + +then: + br label %exit + +else: + br label %exit + +exit: + %result = phi i32 [ %a, %then ], [ %b, %else ] + ret i32 %result +} + +define i32 @zero2(i32 %i, i32 %a, i32 %b) { +; CHECK: Printing analysis {{.*}} for function 'zero2' +entry: + %cond = icmp ne i32 %i, -1 + br i1 %cond, label %then, label %else +; CHECK: edge entry -> then probability is 20 / 32 +; CHECK: edge entry -> else probability is 12 / 32 + +then: + br label %exit + +else: + br label %exit + +exit: + %result = phi i32 [ %a, %then ], [ %b, %else ] + ret i32 %result +} + diff --git a/test/Analysis/BranchProbabilityInfo/lit.local.cfg b/test/Analysis/BranchProbabilityInfo/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/BranchProbabilityInfo/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/CallGraph/lit.local.cfg b/test/Analysis/CallGraph/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/CallGraph/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/CallGraph/no-intrinsics.ll b/test/Analysis/CallGraph/no-intrinsics.ll index 450dce58e30f9..d858907d7247b 100644 --- a/test/Analysis/CallGraph/no-intrinsics.ll +++ b/test/Analysis/CallGraph/no-intrinsics.ll @@ -10,4 +10,4 @@ define void @f(i8* %out, i8* %in) { } ; CHECK: Call graph node for function: 'f' -; CHECK-NOT: calls function 'llvm.memcpy.p0i8.p0i8.i32'
\ No newline at end of file +; CHECK-NOT: calls function 'llvm.memcpy.p0i8.p0i8.i32' diff --git a/test/Analysis/CostModel/ARM/lit.local.cfg b/test/Analysis/CostModel/ARM/lit.local.cfg index cb77b09ef4adb..8a3ba96497e7d 100644 --- a/test/Analysis/CostModel/ARM/lit.local.cfg +++ b/test/Analysis/CostModel/ARM/lit.local.cfg @@ -1,5 +1,3 @@ -config.suffixes = ['.ll', '.c', '.cpp'] - targets = set(config.root.targets_to_build.split()) if not 'ARM' in targets: config.unsupported = True diff --git a/test/Analysis/CostModel/ARM/select.ll b/test/Analysis/CostModel/ARM/select.ll index 34ed1eefdaf42..21eef83c4bbea 100644 --- a/test/Analysis/CostModel/ARM/select.ll +++ b/test/Analysis/CostModel/ARM/select.ll @@ -63,5 +63,13 @@ define void @casts() { ; CHECK: cost of 1 {{.*}} select %v19 = select <2 x i1> undef, <2 x double> undef, <2 x double> undef + ; odd vectors get legalized and should have similar costs + ; CHECK: cost of 1 {{.*}} select + %v20 = select <1 x i1> undef, <1 x i32> undef, <1 x i32> undef + ; CHECK: cost of 1 {{.*}} select + %v21 = select <3 x i1> undef, <3 x float> undef, <3 x float> undef + ; CHECK: cost of 4 {{.*}} select + %v22 = select <5 x i1> undef, <5 x double> undef, <5 x double> undef + ret void } diff --git a/test/Analysis/CostModel/PowerPC/lit.local.cfg b/test/Analysis/CostModel/PowerPC/lit.local.cfg index 4019eca0bb88f..2e463005586fc 100644 --- a/test/Analysis/CostModel/PowerPC/lit.local.cfg +++ b/test/Analysis/CostModel/PowerPC/lit.local.cfg @@ -1,5 +1,3 @@ -config.suffixes = ['.ll', '.c', '.cpp'] - targets = set(config.root.targets_to_build.split()) if not 'PowerPC' in targets: config.unsupported = True diff --git a/test/Analysis/CostModel/X86/cast.ll b/test/Analysis/CostModel/X86/cast.ll index b69b3bf6304c2..f3c1283c7e329 100644 --- a/test/Analysis/CostModel/X86/cast.ll +++ b/test/Analysis/CostModel/X86/cast.ll @@ -38,6 +38,10 @@ define i32 @zext_sext(<8 x i1> %in) { ;CHECK: cost of 9 {{.*}} sext %S = sext <8 x i1> %in to <8 x i32> + ;CHECK: cost of 1 {{.*}} zext + %A1 = zext <16 x i8> undef to <16 x i16> + ;CHECK: cost of 1 {{.*}} sext + %A2 = sext <16 x i8> undef to <16 x i16> ;CHECK: cost of 1 {{.*}} sext %A = sext <8 x i16> undef to <8 x i32> ;CHECK: cost of 1 {{.*}} zext @@ -51,11 +55,13 @@ define i32 @zext_sext(<8 x i1> %in) { ;CHECK: cost of 1 {{.*}} zext %D = zext <4 x i32> undef to <4 x i64> - ;CHECK: cost of 1 {{.*}} trunc + ;CHECK: cost of 1 {{.*}} trunc %E = trunc <4 x i64> undef to <4 x i32> ;CHECK: cost of 1 {{.*}} trunc %F = trunc <8 x i32> undef to <8 x i16> + ;CHECK: cost of 2 {{.*}} trunc + %F1 = trunc <16 x i16> undef to <16 x i8> ;CHECK: cost of 3 {{.*}} trunc %G = trunc <8 x i64> undef to <8 x i32> diff --git a/test/Analysis/CostModel/X86/div.ll b/test/Analysis/CostModel/X86/div.ll new file mode 100644 index 0000000000000..c7d6517c7f03d --- /dev/null +++ b/test/Analysis/CostModel/X86/div.ll @@ -0,0 +1,32 @@ +; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core2 -cost-model -analyze < %s | FileCheck --check-prefix=SSE2 %s +; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core-avx2 -cost-model -analyze < %s | FileCheck --check-prefix=AVX2 %s + + +define void @div_sse() { + ; SSE2: div_sse + ; SSE2: cost of 320 {{.*}} sdiv + %a0 = sdiv <16 x i8> undef, undef + ; SSE2: cost of 160 {{.*}} sdiv + %a1 = sdiv <8 x i16> undef, undef + ; SSE2: cost of 80 {{.*}} sdiv + %a2 = sdiv <4 x i32> undef, undef + ; SSE2: cost of 40 {{.*}} sdiv + %a3 = sdiv <2 x i32> undef, undef + ret void +} +; SSE2: div_avx + +define void @div_avx() { + ; AVX2: div_avx + ; AVX2: cost of 640 {{.*}} sdiv + %a0 = sdiv <32 x i8> undef, undef + ; AVX2: cost of 320 {{.*}} sdiv + %a1 = sdiv <16 x i16> undef, undef + ; AVX2: cost of 160 {{.*}} sdiv + %a2 = sdiv <8 x i32> undef, undef + ; AVX2: cost of 80 {{.*}} sdiv + %a3 = sdiv <4 x i32> undef, undef + ret void +} + + diff --git a/test/Analysis/CostModel/X86/intrinsic-cost.ll b/test/Analysis/CostModel/X86/intrinsic-cost.ll index e235a36222a7e..8eeee8124d9ac 100644 --- a/test/Analysis/CostModel/X86/intrinsic-cost.ll +++ b/test/Analysis/CostModel/X86/intrinsic-cost.ll @@ -30,3 +30,31 @@ for.end: ; preds = %vector.body } declare <4 x float> @llvm.ceil.v4f32(<4 x float>) nounwind readnone + +define void @test2(float* nocapture %f) nounwind { +vector.ph: + br label %vector.body + +vector.body: ; preds = %vector.body, %vector.ph + %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ] + %0 = getelementptr inbounds float* %f, i64 %index + %1 = bitcast float* %0 to <4 x float>* + %wide.load = load <4 x float>* %1, align 4 + %2 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %wide.load) + store <4 x float> %2, <4 x float>* %1, align 4 + %index.next = add i64 %index, 4 + %3 = icmp eq i64 %index.next, 1024 + br i1 %3, label %for.end, label %vector.body + +for.end: ; preds = %vector.body + ret void + +; CORE2: Printing analysis 'Cost Model Analysis' for function 'test2': +; CORE2: Cost Model: Found an estimated cost of 400 for instruction: %2 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %wide.load) + +; COREI7: Printing analysis 'Cost Model Analysis' for function 'test2': +; COREI7: Cost Model: Found an estimated cost of 1 for instruction: %2 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %wide.load) + +} + +declare <4 x float> @llvm.nearbyint.v4f32(<4 x float>) nounwind readnone diff --git a/test/Analysis/CostModel/X86/lit.local.cfg b/test/Analysis/CostModel/X86/lit.local.cfg index a8ad0f1a28b23..ba763cf03ffcc 100644 --- a/test/Analysis/CostModel/X86/lit.local.cfg +++ b/test/Analysis/CostModel/X86/lit.local.cfg @@ -1,5 +1,3 @@ -config.suffixes = ['.ll', '.c', '.cpp'] - targets = set(config.root.targets_to_build.split()) if not 'X86' in targets: config.unsupported = True diff --git a/test/Analysis/CostModel/X86/load_store.ll b/test/Analysis/CostModel/X86/load_store.ll index 4195b1d879a15..a53d0bd4e993e 100644 --- a/test/Analysis/CostModel/X86/load_store.ll +++ b/test/Analysis/CostModel/X86/load_store.ll @@ -59,6 +59,25 @@ define i32 @loads(i32 %arg) { ;CHECK: cost of 4 {{.*}} load load <8 x i64>* undef, align 4 + + ;CHECK: cost of 3 {{.*}} load + load <3 x float>* undef, align 4 + + ;CHECK: cost of 3 {{.*}} load + load <3 x double>* undef, align 4 + + ;CHECK: cost of 3 {{.*}} load + load <3 x i32>* undef, align 4 + + ;CHECK: cost of 3 {{.*}} load + load <3 x i64>* undef, align 4 + + ;CHECK: cost of 10 {{.*}} load + load <5 x i32>* undef, align 4 + + ;CHECK: cost of 10 {{.*}} load + load <5 x i64>* undef, align 4 + ret i32 undef } diff --git a/test/Analysis/CostModel/X86/reduction.ll b/test/Analysis/CostModel/X86/reduction.ll new file mode 100644 index 0000000000000..78e65aee14609 --- /dev/null +++ b/test/Analysis/CostModel/X86/reduction.ll @@ -0,0 +1,365 @@ +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=core2 -mtriple=x86_64-apple-darwin | FileCheck %s +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=corei7 -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=SSE3 +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=corei7-avx -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=AVX +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=core-avx2 -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=AVX2 + +define fastcc float @reduction_cost_float(<4 x float> %rdx) { + %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x float> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7 + +; Check that we recognize the tree starting at the extractelement as a +; reduction. +; CHECK-LABEL: reduction_cost +; CHECK: cost of 9 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc i32 @reduction_cost_int(<8 x i32> %rdx) { + %rdx.shuf = shufflevector <8 x i32> %rdx, <8 x i32> undef, + <8 x i32> <i32 4 , i32 5, i32 6, i32 7, + i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i32> %rdx, %rdx.shuf + %rdx.shuf.2 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef, + <8 x i32> <i32 2 , i32 3, i32 undef, i32 undef, + i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx.2 = add <8 x i32> %bin.rdx, %rdx.shuf.2 + %rdx.shuf.3 = shufflevector <8 x i32> %bin.rdx.2, <8 x i32> undef, + <8 x i32> <i32 1 , i32 undef, i32 undef, i32 undef, + i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx.3 = add <8 x i32> %bin.rdx.2, %rdx.shuf.3 + +; CHECK-LABEL: reduction_cost_int +; CHECK: cost of 23 {{.*}} extractelement + + %r = extractelement <8 x i32> %bin.rdx.3, i32 0 + ret i32 %r +} + +define fastcc float @pairwise_hadd(<4 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, + <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef, + <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, + <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, + <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx.1 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; CHECK-LABEL: pairwise_hadd +; CHECK: cost of 11 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx.1, i32 0 + %r2 = fadd float %r, %f1 + ret float %r2 +} + +define fastcc float @pairwise_hadd_assoc(<4 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, + <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef, + <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.1, %rdx.shuf.0.0 + %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, + <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, + <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx.1 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; CHECK-LABEL: pairwise_hadd_assoc +; CHECK: cost of 11 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx.1, i32 0 + %r2 = fadd float %r, %f1 + ret float %r2 +} + +define fastcc float @pairwise_hadd_skip_first(<4 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, + <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef, + <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, + <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx.1 = fadd <4 x float> %bin.rdx.0, %rdx.shuf.1.1 + +; CHECK-LABEL: pairwise_hadd_skip_first +; CHECK: cost of 11 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx.1, i32 0 + %r2 = fadd float %r, %f1 + ret float %r2 +} + +define fastcc double @no_pairwise_reduction2double(<2 x double> %rdx, double %f1) { + %rdx.shuf = shufflevector <2 x double> %rdx, <2 x double> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx = fadd <2 x double> %rdx, %rdx.shuf + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 2 {{.*}} extractelement +; AVX2: cost of 2 {{.*}} extractelement + + %r = extractelement <2 x double> %bin.rdx, i32 0 + ret double %r +} + +define fastcc float @no_pairwise_reduction4float(<4 x float> %rdx, float %f1) { + %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x float> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7 + +; SSE3: cost of 4 {{.*}} extractelement +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc double @no_pairwise_reduction4double(<4 x double> %rdx, double %f1) { + %rdx.shuf = shufflevector <4 x double> %rdx, <4 x double> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x double> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x double> %bin.rdx, <4 x double> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x double> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x double> %bin.rdx8, i32 0 + ret double %r +} + +define fastcc float @no_pairwise_reduction8float(<8 x float> %rdx, float %f1) { + %rdx.shuf3 = shufflevector <8 x float> %rdx, <8 x float> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx4 = fadd <8 x float> %rdx, %rdx.shuf3 + %rdx.shuf = shufflevector <8 x float> %bin.rdx4, <8 x float> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = fadd <8 x float> %bin.rdx4, %rdx.shuf + %rdx.shuf7 = shufflevector <8 x float> %bin.rdx, <8 x float> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <8 x float> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 4 {{.*}} extractelement +; AVX2: cost of 4 {{.*}} extractelement + + %r = extractelement <8 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc i64 @no_pairwise_reduction2i64(<2 x i64> %rdx, i64 %f1) { + %rdx.shuf = shufflevector <2 x i64> %rdx, <2 x i64> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx = add <2 x i64> %rdx, %rdx.shuf + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 1 {{.*}} extractelement +; AVX2: cost of 1 {{.*}} extractelement + + %r = extractelement <2 x i64> %bin.rdx, i32 0 + ret i64 %r +} + +define fastcc i32 @no_pairwise_reduction4i32(<4 x i32> %rdx, i32 %f1) { + %rdx.shuf = shufflevector <4 x i32> %rdx, <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i32> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i32> %bin.rdx, %rdx.shuf7 + +; SSE3: cost of 3 {{.*}} extractelement +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x i32> %bin.rdx8, i32 0 + ret i32 %r +} + +define fastcc i64 @no_pairwise_reduction4i64(<4 x i64> %rdx, i64 %f1) { + %rdx.shuf = shufflevector <4 x i64> %rdx, <4 x i64> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i64> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x i64> %bin.rdx, <4 x i64> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i64> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x i64> %bin.rdx8, i32 0 + ret i64 %r +} + +define fastcc i16 @no_pairwise_reduction8i16(<8 x i16> %rdx, i16 %f1) { + %rdx.shuf3 = shufflevector <8 x i16> %rdx, <8 x i16> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx4 = add <8 x i16> %rdx, %rdx.shuf3 + %rdx.shuf = shufflevector <8 x i16> %bin.rdx4, <8 x i16> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i16> %bin.rdx4, %rdx.shuf + %rdx.shuf7 = shufflevector <8 x i16> %bin.rdx, <8 x i16> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i16> %bin.rdx, %rdx.shuf7 + +; SSE3: cost of 4 {{.*}} extractelement +; AVX: cost of 4 {{.*}} extractelement +; AVX2: cost of 4 {{.*}} extractelement + + %r = extractelement <8 x i16> %bin.rdx8, i32 0 + ret i16 %r +} + +define fastcc i32 @no_pairwise_reduction8i32(<8 x i32> %rdx, i32 %f1) { + %rdx.shuf3 = shufflevector <8 x i32> %rdx, <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx4 = add <8 x i32> %rdx, %rdx.shuf3 + %rdx.shuf = shufflevector <8 x i32> %bin.rdx4, <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i32> %bin.rdx4, %rdx.shuf + %rdx.shuf7 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i32> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <8 x i32> %bin.rdx8, i32 0 + ret i32 %r +} + +define fastcc double @pairwise_reduction2double(<2 x double> %rdx, double %f1) { + %rdx.shuf.1.0 = shufflevector <2 x double> %rdx, <2 x double> undef, <2 x i32> <i32 0, i32 undef> + %rdx.shuf.1.1 = shufflevector <2 x double> %rdx, <2 x double> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx8 = fadd <2 x double> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 2 {{.*}} extractelement +; AVX2: cost of 2 {{.*}} extractelement + + %r = extractelement <2 x double> %bin.rdx8, i32 0 + ret double %r +} + +define fastcc float @pairwise_reduction4float(<4 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 4 {{.*}} extractelement +; AVX: cost of 4 {{.*}} extractelement +; AVX2: cost of 4 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc double @pairwise_reduction4double(<4 x double> %rdx, double %f1) { + %rdx.shuf.0.0 = shufflevector <4 x double> %rdx, <4 x double> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x double> %rdx, <4 x double> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x double> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x double> %bin.rdx, <4 x double> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x double> %bin.rdx, <4 x double> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x double> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <4 x double> %bin.rdx8, i32 0 + ret double %r +} + +define fastcc float @pairwise_reduction8float(<8 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <8 x float> %rdx, <8 x float> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6,i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <8 x float> %rdx, <8 x float> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = fadd <8 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <8 x float> %bin.rdx, <8 x float> undef,<8 x i32> <i32 0, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <8 x float> %bin.rdx, <8 x float> undef,<8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <8 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 + %rdx.shuf.2.0 = shufflevector <8 x float> %bin.rdx8, <8 x float> undef,<8 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.2.1 = shufflevector <8 x float> %bin.rdx8, <8 x float> undef,<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx9 = fadd <8 x float> %rdx.shuf.2.0, %rdx.shuf.2.1 + +; AVX: cost of 7 {{.*}} extractelement +; AVX2: cost of 7 {{.*}} extractelement + + %r = extractelement <8 x float> %bin.rdx9, i32 0 + ret float %r +} + +define fastcc i64 @pairwise_reduction2i64(<2 x i64> %rdx, i64 %f1) { + %rdx.shuf.1.0 = shufflevector <2 x i64> %rdx, <2 x i64> undef, <2 x i32> <i32 0, i32 undef> + %rdx.shuf.1.1 = shufflevector <2 x i64> %rdx, <2 x i64> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx8 = add <2 x i64> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 1 {{.*}} extractelement +; AVX2: cost of 1 {{.*}} extractelement + + %r = extractelement <2 x i64> %bin.rdx8, i32 0 + ret i64 %r +} + +define fastcc i32 @pairwise_reduction4i32(<4 x i32> %rdx, i32 %f1) { + %rdx.shuf.0.0 = shufflevector <4 x i32> %rdx, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x i32> %rdx, <4 x i32> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i32> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i32> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 3 {{.*}} extractelement +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x i32> %bin.rdx8, i32 0 + ret i32 %r +} + +define fastcc i64 @pairwise_reduction4i64(<4 x i64> %rdx, i64 %f1) { + %rdx.shuf.0.0 = shufflevector <4 x i64> %rdx, <4 x i64> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x i64> %rdx, <4 x i64> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i64> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x i64> %bin.rdx, <4 x i64> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x i64> %bin.rdx, <4 x i64> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i64> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <4 x i64> %bin.rdx8, i32 0 + ret i64 %r +} + +define fastcc i16 @pairwise_reduction8i16(<8 x i16> %rdx, i16 %f1) { + %rdx.shuf.0.0 = shufflevector <8 x i16> %rdx, <8 x i16> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6,i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <8 x i16> %rdx, <8 x i16> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i16> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <8 x i16> %bin.rdx, <8 x i16> undef,<8 x i32> <i32 0, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <8 x i16> %bin.rdx, <8 x i16> undef,<8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i16> %rdx.shuf.1.0, %rdx.shuf.1.1 + %rdx.shuf.2.0 = shufflevector <8 x i16> %bin.rdx8, <8 x i16> undef,<8 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.2.1 = shufflevector <8 x i16> %bin.rdx8, <8 x i16> undef,<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx9 = add <8 x i16> %rdx.shuf.2.0, %rdx.shuf.2.1 + +; SSE3: cost of 5 {{.*}} extractelement +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <8 x i16> %bin.rdx9, i32 0 + ret i16 %r +} + +define fastcc i32 @pairwise_reduction8i32(<8 x i32> %rdx, i32 %f1) { + %rdx.shuf.0.0 = shufflevector <8 x i32> %rdx, <8 x i32> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6,i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <8 x i32> %rdx, <8 x i32> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i32> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef,<8 x i32> <i32 0, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef,<8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i32> %rdx.shuf.1.0, %rdx.shuf.1.1 + %rdx.shuf.2.0 = shufflevector <8 x i32> %bin.rdx8, <8 x i32> undef,<8 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.2.1 = shufflevector <8 x i32> %bin.rdx8, <8 x i32> undef,<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx9 = add <8 x i32> %rdx.shuf.2.0, %rdx.shuf.2.1 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <8 x i32> %bin.rdx9, i32 0 + ret i32 %r +} diff --git a/test/Analysis/CostModel/lit.local.cfg b/test/Analysis/CostModel/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/CostModel/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/Delinearization/a.ll b/test/Analysis/Delinearization/a.ll new file mode 100644 index 0000000000000..9308749b2792e --- /dev/null +++ b/test/Analysis/Delinearization/a.ll @@ -0,0 +1,74 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s +; +; void foo(long n, long m, long o, int A[n][m][o]) { +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; for (long k = 0; k < o; k++) +; A[2*i+3][3*j-4][5*k+7] = 1; +; } + +; AddRec: {{{(28 + (4 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(12 * %o)}<%for.j>,+,20}<%for.k> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(i32) bytes. +; CHECK: ArrayRef[{3,+,2}<%for.i>][{-4,+,3}<%for.j>][{7,+,5}<%for.k>] + +; AddRec: {{(8 + ((4 + (12 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(12 * %o)}<%for.j> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%o] with elements of sizeof(i32) bytes. +; CHECK: ArrayRef[{(1 + (3 * %m)),+,(2 * %m)}<%for.i>][{2,+,(3 * %o)}<%for.j>] + +; AddRec: {(8 + ((-8 + (24 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of 2 bytes. +; CHECK: ArrayRef[{((1 + ((-1 + (3 * %m)) * %o)) * sizeof(i32)),+,(%m * %o * sizeof(i32))}<%for.i>] + +; Function Attrs: nounwind uwtable +define void @foo(i64 %n, i64 %m, i64 %o, i32* nocapture %A) #0 { +entry: + %cmp32 = icmp sgt i64 %n, 0 + br i1 %cmp32, label %for.cond1.preheader.lr.ph, label %for.end17 + +for.cond1.preheader.lr.ph: ; preds = %entry + %cmp230 = icmp sgt i64 %m, 0 + %cmp528 = icmp sgt i64 %o, 0 + br i1 %cmp230, label %for.i, label %for.end17 + +for.inc15.us: ; preds = %for.inc12.us.us, %for.i + %inc16.us = add nsw i64 %i.033.us, 1 + %exitcond55 = icmp eq i64 %inc16.us, %n + br i1 %exitcond55, label %for.end17, label %for.i + +for.i: ; preds = %for.cond1.preheader.lr.ph, %for.inc15.us + %i.033.us = phi i64 [ %inc16.us, %for.inc15.us ], [ 0, %for.cond1.preheader.lr.ph ] + %mul8.us = shl i64 %i.033.us, 1 + %add9.us = add nsw i64 %mul8.us, 3 + %0 = mul i64 %add9.us, %m + %sub.us = add i64 %0, -4 + br i1 %cmp528, label %for.j, label %for.inc15.us + +for.inc12.us.us: ; preds = %for.k + %inc13.us.us = add nsw i64 %j.031.us.us, 1 + %exitcond54 = icmp eq i64 %inc13.us.us, %m + br i1 %exitcond54, label %for.inc15.us, label %for.j + +for.j: ; preds = %for.i, %for.inc12.us.us + %j.031.us.us = phi i64 [ %inc13.us.us, %for.inc12.us.us ], [ 0, %for.i ] + %mul7.us.us = mul nsw i64 %j.031.us.us, 3 + %tmp.us.us = add i64 %sub.us, %mul7.us.us + %tmp27.us.us = mul i64 %tmp.us.us, %o + br label %for.k + +for.k: ; preds = %for.k, %for.j + %k.029.us.us = phi i64 [ 0, %for.j ], [ %inc.us.us, %for.k ] + %mul.us.us = mul nsw i64 %k.029.us.us, 5 + %arrayidx.sum.us.us = add i64 %mul.us.us, 7 + %arrayidx10.sum.us.us = add i64 %arrayidx.sum.us.us, %tmp27.us.us + %arrayidx11.us.us = getelementptr inbounds i32* %A, i64 %arrayidx10.sum.us.us + store i32 1, i32* %arrayidx11.us.us, align 4 + %inc.us.us = add nsw i64 %k.029.us.us, 1 + %exitcond = icmp eq i64 %inc.us.us, %o + br i1 %exitcond, label %for.inc12.us.us, label %for.k + +for.end17: ; preds = %for.inc15.us, %for.cond1.preheader.lr.ph, %entry + ret void +} diff --git a/test/Analysis/Delinearization/himeno_1.ll b/test/Analysis/Delinearization/himeno_1.ll new file mode 100644 index 0000000000000..9458bd2e52610 --- /dev/null +++ b/test/Analysis/Delinearization/himeno_1.ll @@ -0,0 +1,102 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; #define MR(mt,n,r,c,d) mt->m[(n) * mt->mrows * mt->mcols * mt->mdeps + (r) * mt->mcols* mt->mdeps + (c) * mt->mdeps + (d)] +; +; struct Mat { +; float* m; +; int mnums; +; int mrows; +; int mcols; +; int mdeps; +; }; +; +; typedef struct Mat Matrix; +; +; void jacobi(int nn, Matrix* a, Matrix* p) +; { +; long i, j, k, max,jmax,kmax; +; +; p_rows_sub = p->mrows - 1; +; p_cols_sub = p->mcols - 1; +; p_deps_sub = p->mdeps - 1; +; +; for(i = 1; i < p_rows_sub; i++) +; for(j = 1; j < p_cols_sub; j++) +; for(k = 1; k < p_deps_sub; k++) +; MR(a,0,i,j,k) = i + j + k; +; } + +; AddRec: {{{(4 + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j>,+,4}<%for.k> +; CHECK: Base offset: %a.base +; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes. +; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>] + +; AddRec: {{(-4 + (4 * (sext i32 (-1 + %p.deps) to i64)) + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j> +; CHECK: Base offset: %a.base +; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes. +; CHECK: ArrayRef[{(1 + (sext i32 %a.cols to i64)),+,(sext i32 %a.cols to i64)}<%for.i>][{(-1 + (sext i32 (-1 + %p.deps) to i64)),+,(sext i32 %a.deps to i64)}<%for.j>] + +; AddRec: {(-4 + (4 * (sext i32 (-1 + %p.deps) to i64)) + ((sext i32 %a.deps to i64) * (-4 + (4 * (sext i32 (-1 + %p.cols) to i64)) + (4 * (sext i32 %a.cols to i64)))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i> +; CHECK: Base offset: %a.base +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(float) bytes. +; CHECK: ArrayRef[{(-1 + (sext i32 (-1 + %p.deps) to i64) + ((sext i32 %a.deps to i64) * (-1 + (sext i32 (-1 + %p.cols) to i64) + (sext i32 %a.cols to i64)))),+,((sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>] + +%struct.Mat = type { float*, i32, i32, i32, i32 } + +define void @jacobi(i32 %nn, %struct.Mat* nocapture %a, %struct.Mat* nocapture %p) nounwind uwtable { +entry: + %p.rows.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 2 + %p.rows = load i32* %p.rows.ptr + %p.rows.sub = add i32 %p.rows, -1 + %p.rows.sext = sext i32 %p.rows.sub to i64 + %p.cols.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 3 + %p.cols = load i32* %p.cols.ptr + %p.cols.sub = add i32 %p.cols, -1 + %p.cols.sext = sext i32 %p.cols.sub to i64 + %p.deps.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 4 + %p.deps = load i32* %p.deps.ptr + %p.deps.sub = add i32 %p.deps, -1 + %p.deps.sext = sext i32 %p.deps.sub to i64 + %a.cols.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 3 + %a.cols = load i32* %a.cols.ptr + %a.deps.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 4 + %a.deps = load i32* %a.deps.ptr + %a.base.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 0 + %a.base = load float** %a.base.ptr, align 8 + br label %for.i + +for.i: ; preds = %for.i.inc, %entry + %i = phi i64 [ %i.inc, %for.i.inc ], [ 1, %entry ] + br label %for.j + +for.j: ; preds = %for.j.inc, %for.i + %j = phi i64 [ %j.inc, %for.j.inc ], [ 1, %for.i ] + %a.cols.sext = sext i32 %a.cols to i64 + %a.deps.sext = sext i32 %a.deps to i64 + br label %for.k + +for.k: ; preds = %for.k, %for.j + %k = phi i64 [ 1, %for.j ], [ %k.inc, %for.k ] + %tmp1 = mul nsw i64 %a.cols.sext, %i + %tmp2 = add i64 %tmp1, %j + %tmp3 = mul i64 %tmp2, %a.deps.sext + %tmp4 = add nsw i64 %k, %tmp3 + %arrayidx = getelementptr inbounds float* %a.base, i64 %tmp4 + store float 1.000000e+00, float* %arrayidx + %k.inc = add nsw i64 %k, 1 + %k.exitcond = icmp eq i64 %k.inc, %p.deps.sext + br i1 %k.exitcond, label %for.j.inc, label %for.k + +for.j.inc: ; preds = %for.k + %j.inc = add nsw i64 %j, 1 + %j.exitcond = icmp eq i64 %j.inc, %p.cols.sext + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: ; preds = %for.j.inc + %i.inc = add nsw i64 %i, 1 + %i.exitcond = icmp eq i64 %i.inc, %p.rows.sext + br i1 %i.exitcond, label %end, label %for.i + +end: ; preds = %for.i.inc + ret void +} diff --git a/test/Analysis/Delinearization/himeno_2.ll b/test/Analysis/Delinearization/himeno_2.ll new file mode 100644 index 0000000000000..a29006606fab9 --- /dev/null +++ b/test/Analysis/Delinearization/himeno_2.ll @@ -0,0 +1,102 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; #define MR(mt,n,r,c,d) mt->m[(n) * mt->mrows * mt->mcols * mt->mdeps + (r) * mt->mcols* mt->mdeps + (c) * mt->mdeps + (d)] +; +; struct Mat { +; float* m; +; int mnums; +; int mrows; +; int mcols; +; int mdeps; +; }; +; +; typedef struct Mat Matrix; +; +; void jacobi(int nn, Matrix* a, Matrix* p) +; { +; long i, j, k, max,jmax,kmax; +; +; p_rows_sub = p->mrows - 1; +; p_cols_sub = p->mcols - 1; +; p_deps_sub = p->mdeps - 1; +; +; for(i = 1; i < p_rows_sub; i++) +; for(j = 1; j < p_cols_sub; j++) +; for(k = 1; k < p_deps_sub; k++) +; MR(a,0,i,j,k) = i + j + k; +; } + +; AddRec: {{{(4 + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j>,+,4}<%for.k> +; CHECK: Base offset: %a.base +; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes. +; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>] + +; AddRec: {{(-4 + (4 * (sext i32 (-1 + %p.deps) to i64)) + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j> +; CHECK: Base offset: %a.base +; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes. +; CHECK: ArrayRef[{(1 + (sext i32 %a.cols to i64)),+,(sext i32 %a.cols to i64)}<%for.i>][{(-1 + (sext i32 (-1 + %p.deps) to i64)),+,(sext i32 %a.deps to i64)}<%for.j>] + +; AddRec: {(-4 + (4 * (sext i32 (-1 + %p.deps) to i64)) + ((sext i32 %a.deps to i64) * (-4 + (4 * (sext i32 (-1 + %p.cols) to i64)) + (4 * (sext i32 %a.cols to i64)))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i> +; CHECK: Base offset: %a.base +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(float) bytes. +; CHECK: ArrayRef[{(-1 + (sext i32 (-1 + %p.deps) to i64) + ((sext i32 %a.deps to i64) * (-1 + (sext i32 (-1 + %p.cols) to i64) + (sext i32 %a.cols to i64)))),+,((sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>] + +%struct.Mat = type { float*, i32, i32, i32, i32 } + +define void @jacobi(i32 %nn, %struct.Mat* nocapture %a, %struct.Mat* nocapture %p) nounwind uwtable { +entry: + %p.rows.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 2 + %p.rows = load i32* %p.rows.ptr + %p.rows.sub = add i32 %p.rows, -1 + %p.rows.sext = sext i32 %p.rows.sub to i64 + %p.cols.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 3 + %p.cols = load i32* %p.cols.ptr + %p.cols.sub = add i32 %p.cols, -1 + %p.cols.sext = sext i32 %p.cols.sub to i64 + %p.deps.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 4 + %p.deps = load i32* %p.deps.ptr + %p.deps.sub = add i32 %p.deps, -1 + %p.deps.sext = sext i32 %p.deps.sub to i64 + %a.cols.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 3 + %a.cols = load i32* %a.cols.ptr + %a.cols.sext = sext i32 %a.cols to i64 + %a.deps.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 4 + %a.deps = load i32* %a.deps.ptr + %a.deps.sext = sext i32 %a.deps to i64 + %a.base.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 0 + %a.base = load float** %a.base.ptr, align 8 + br label %for.i + +for.i: ; preds = %for.i.inc, %entry + %i = phi i64 [ %i.inc, %for.i.inc ], [ 1, %entry ] + br label %for.j + +for.j: ; preds = %for.j.inc, %for.i + %j = phi i64 [ %j.inc, %for.j.inc ], [ 1, %for.i ] + br label %for.k + +for.k: ; preds = %for.k, %for.j + %k = phi i64 [ 1, %for.j ], [ %k.inc, %for.k ] + %tmp1 = mul nsw i64 %a.cols.sext, %i + %tmp2 = add i64 %tmp1, %j + %tmp3 = mul i64 %tmp2, %a.deps.sext + %tmp4 = add nsw i64 %k, %tmp3 + %arrayidx = getelementptr inbounds float* %a.base, i64 %tmp4 + store float 1.000000e+00, float* %arrayidx + %k.inc = add nsw i64 %k, 1 + %k.exitcond = icmp eq i64 %k.inc, %p.deps.sext + br i1 %k.exitcond, label %for.j.inc, label %for.k + +for.j.inc: ; preds = %for.k + %j.inc = add nsw i64 %j, 1 + %j.exitcond = icmp eq i64 %j.inc, %p.cols.sext + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: ; preds = %for.j.inc + %i.inc = add nsw i64 %i, 1 + %i.exitcond = icmp eq i64 %i.inc, %p.rows.sext + br i1 %i.exitcond, label %end, label %for.i + +end: ; preds = %for.i.inc + ret void +} diff --git a/test/Analysis/BasicAA/lit.local.cfg b/test/Analysis/Delinearization/lit.local.cfg index 19eebc0ac7ac3..19eebc0ac7ac3 100644 --- a/test/Analysis/BasicAA/lit.local.cfg +++ b/test/Analysis/Delinearization/lit.local.cfg diff --git a/test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_3d.ll b/test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_3d.ll new file mode 100644 index 0000000000000..82cab167c74f7 --- /dev/null +++ b/test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_3d.ll @@ -0,0 +1,68 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; void foo(long n, long m, long o, double A[n][m][o]) { +; +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; for (long k = 0; k < o; k++) +; A[i+3][j-4][k+7] = 1.0; +; } + +; AddRec: {{{(56 + (8 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j>,+,8}<%for.k> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{3,+,1}<nw><%for.i>][{-4,+,1}<nw><%for.j>][{7,+,1}<nw><%for.k>] + +; AddRec: {{(48 + ((-24 + (24 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%o] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(-3 + (3 * %m)),+,%m}<%for.i>][{6,+,%o}<%for.j>] + +; AddRec: {(48 + ((-32 + (32 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(6 + ((-4 + (4 * %m)) * %o)),+,(%m * %o)}<%for.i>] + +define void @foo(i64 %n, i64 %m, i64 %o, double* %A) { +entry: + br label %for.i + +for.i: + %i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ] + br label %for.j + +for.j: + %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ] + br label %for.k + +for.k: + %k = phi i64 [ 0, %for.j ], [ %k.inc, %for.k.inc ] + %offset0 = add nsw i64 %i, 3 + %subscript0 = mul i64 %offset0, %m + %offset1 = add nsw i64 %j, -4 + %subscript1 = add i64 %offset1, %subscript0 + %subscript2 = mul i64 %subscript1, %o + %offset2 = add nsw i64 %k, 7 + %subscript = add i64 %subscript2, %offset2 + %idx = getelementptr inbounds double* %A, i64 %subscript + store double 1.0, double* %idx + br label %for.k.inc + +for.k.inc: + %k.inc = add nsw i64 %k, 1 + %k.exitcond = icmp eq i64 %k.inc, %o + br i1 %k.exitcond, label %for.j.inc, label %for.k + +for.j.inc: + %j.inc = add nsw i64 %j, 1 + %j.exitcond = icmp eq i64 %j.inc, %m + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: + %i.inc = add nsw i64 %i, 1 + %i.exitcond = icmp eq i64 %i.inc, %n + br i1 %i.exitcond, label %end, label %for.i + +end: + ret void +} diff --git a/test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_nts_3d.ll b/test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_nts_3d.ll new file mode 100644 index 0000000000000..a1e779fff6c9f --- /dev/null +++ b/test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_nts_3d.ll @@ -0,0 +1,72 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; void foo(long n, long m, long o, long p, double A[n][m][o+p]) { +; +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; for (long k = 0; k < o; k++) +; A[i+3][j-4][k+7] = 1.0; +; } + +; AddRec: {{{(56 + (8 * (-4 + (3 * %m)) * (%o + %p)) + %A),+,(8 * (%o + %p) * %m)}<%for.cond4.preheader.lr.ph.us>,+,(8 * (%o + %p))}<%for.body6.lr.ph.us.us>,+,8}<%for.body6.us.us> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%m][(%o + %p)] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{3,+,1}<nw><%for.cond4.preheader.lr.ph.us>][{-4,+,1}<nw><%for.body6.lr.ph.us.us>][{7,+,1}<nw><%for.body6.us.us>] + +; AddRec: {{(48 + (8 * %o) + (8 * (-4 + (3 * %m)) * (%o + %p)) + %A),+,(8 * (%o + %p) * %m)}<%for.cond4.preheader.lr.ph.us>,+,(8 * (%o + %p))}<%for.body6.lr.ph.us.us> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][(%o + %p)] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(-4 + (3 * %m)),+,%m}<%for.cond4.preheader.lr.ph.us>][{(6 + %o),+,(%o + %p)}<%for.body6.lr.ph.us.us>] + +; AddRec: {(48 + (8 * %o) + ((-40 + (32 * %m)) * (%o + %p)) + %A),+,(8 * (%o + %p) * %m)}<%for.cond4.preheader.lr.ph.us> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(6 + ((-5 + (4 * %m)) * (%o + %p)) + %o),+,((%o + %p) * %m)}<%for.cond4.preheader.lr.ph.us>] + +define void @foo(i64 %n, i64 %m, i64 %o, i64 %p, double* nocapture %A) nounwind uwtable { +entry: + %add = add nsw i64 %p, %o + %cmp22 = icmp sgt i64 %n, 0 + br i1 %cmp22, label %for.cond1.preheader.lr.ph, label %for.end16 + +for.cond1.preheader.lr.ph: ; preds = %entry + %cmp220 = icmp sgt i64 %m, 0 + %cmp518 = icmp sgt i64 %o, 0 + br i1 %cmp220, label %for.cond4.preheader.lr.ph.us, label %for.end16 + +for.inc14.us: ; preds = %for.cond4.preheader.lr.ph.us, %for.inc11.us.us + %inc15.us = add nsw i64 %i.023.us, 1 + %exitcond43 = icmp eq i64 %inc15.us, %n + br i1 %exitcond43, label %for.end16, label %for.cond4.preheader.lr.ph.us + +for.cond4.preheader.lr.ph.us: ; preds = %for.inc14.us, %for.cond1.preheader.lr.ph + %i.023.us = phi i64 [ %inc15.us, %for.inc14.us ], [ 0, %for.cond1.preheader.lr.ph ] + %add8.us = add nsw i64 %i.023.us, 3 + %0 = mul i64 %add8.us, %m + %sub.us = add i64 %0, -4 + br i1 %cmp518, label %for.body6.lr.ph.us.us, label %for.inc14.us + +for.inc11.us.us: ; preds = %for.body6.us.us + %inc12.us.us = add nsw i64 %j.021.us.us, 1 + %exitcond42 = icmp eq i64 %inc12.us.us, %m + br i1 %exitcond42, label %for.inc14.us, label %for.body6.lr.ph.us.us + +for.body6.lr.ph.us.us: ; preds = %for.cond4.preheader.lr.ph.us, %for.inc11.us.us + %j.021.us.us = phi i64 [ %inc12.us.us, %for.inc11.us.us ], [ 0, %for.cond4.preheader.lr.ph.us ] + %tmp.us.us = add i64 %sub.us, %j.021.us.us + %tmp17.us.us = mul i64 %tmp.us.us, %add + br label %for.body6.us.us + +for.body6.us.us: ; preds = %for.body6.us.us, %for.body6.lr.ph.us.us + %k.019.us.us = phi i64 [ 0, %for.body6.lr.ph.us.us ], [ %inc.us.us, %for.body6.us.us ] + %arrayidx.sum.us.us = add i64 %k.019.us.us, 7 + %arrayidx9.sum.us.us = add i64 %arrayidx.sum.us.us, %tmp17.us.us + %arrayidx10.us.us = getelementptr inbounds double* %A, i64 %arrayidx9.sum.us.us + store double 1.000000e+00, double* %arrayidx10.us.us, align 8 + %inc.us.us = add nsw i64 %k.019.us.us, 1 + %exitcond = icmp eq i64 %inc.us.us, %o + br i1 %exitcond, label %for.inc11.us.us, label %for.body6.us.us + +for.end16: ; preds = %for.cond1.preheader.lr.ph, %for.inc14.us, %entry + ret void +} diff --git a/test/Analysis/Delinearization/multidim_ivs_and_parameteric_offsets_3d.ll b/test/Analysis/Delinearization/multidim_ivs_and_parameteric_offsets_3d.ll new file mode 100644 index 0000000000000..a52a4c93ce23f --- /dev/null +++ b/test/Analysis/Delinearization/multidim_ivs_and_parameteric_offsets_3d.ll @@ -0,0 +1,68 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; void foo(long n, long m, long o, double A[n][m][o], long p, long q, long r) { +; +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; for (long k = 0; k < o; k++) +; A[i+p][j+q][k+r] = 1.0; +; } + +; AddRec: {{{((8 * ((((%m * %p) + %q) * %o) + %r)) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j>,+,8}<%for.k> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{%p,+,1}<nw><%for.i>][{%q,+,1}<nw><%for.j>][{%r,+,1}<nw><%for.k>] + +; AddRec: {{(-8 + (8 * ((((%m * %p) + %q) * %o) + %r)) + (8 * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%o] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(1 + (%m * %p) + %q),+,%m}<%for.i>][{(-1 + %r),+,%o}<%for.j>] + +; AddRec: {(-8 + (8 * ((((%m * %p) + %q) * %o) + %r)) + (8 * %m * %o) + %A),+,(8 * %m * %o)}<%for.i> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(-1 + ((((1 + %p) * %m) + %q) * %o) + %r),+,(%m * %o)}<%for.i>] + +define void @foo(i64 %n, i64 %m, i64 %o, double* %A, i64 %p, i64 %q, i64 %r) { +entry: + br label %for.i + +for.i: + %i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ] + br label %for.j + +for.j: + %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ] + br label %for.k + +for.k: + %k = phi i64 [ 0, %for.j ], [ %k.inc, %for.k.inc ] + %offset0 = add nsw i64 %i, %p + %subscript0 = mul i64 %offset0, %m + %offset1 = add nsw i64 %j, %q + %subscript1 = add i64 %offset1, %subscript0 + %subscript2 = mul i64 %subscript1, %o + %offset2 = add nsw i64 %k, %r + %subscript = add i64 %subscript2, %offset2 + %idx = getelementptr inbounds double* %A, i64 %subscript + store double 1.0, double* %idx + br label %for.k.inc + +for.k.inc: + %k.inc = add nsw i64 %k, 1 + %k.exitcond = icmp eq i64 %k.inc, %o + br i1 %k.exitcond, label %for.j.inc, label %for.k + +for.j.inc: + %j.inc = add nsw i64 %j, 1 + %j.exitcond = icmp eq i64 %j.inc, %m + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: + %i.inc = add nsw i64 %i, 1 + %i.exitcond = icmp eq i64 %i.inc, %n + br i1 %i.exitcond, label %end, label %for.i + +end: + ret void +} diff --git a/test/Analysis/Delinearization/multidim_only_ivs_2d.ll b/test/Analysis/Delinearization/multidim_only_ivs_2d.ll new file mode 100644 index 0000000000000..d68a15883942e --- /dev/null +++ b/test/Analysis/Delinearization/multidim_only_ivs_2d.ll @@ -0,0 +1,46 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; Derived from the following code: +; +; void foo(long n, long m, double A[n][m]) { +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; A[i][j] = 1.0; +; } + +; AddRec: {{%A,+,(8 * %m)}<%for.i>,+,8}<%for.j> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%m] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>] + +; AddRec: {(-8 + (8 * %m) + %A),+,(8 * %m)}<%for.i> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(-1 + %m),+,%m}<%for.i>] + +define void @foo(i64 %n, i64 %m, double* %A) { +entry: + br label %for.i + +for.i: + %i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ] + %tmp = mul nsw i64 %i, %m + br label %for.j + +for.j: + %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j ] + %vlaarrayidx.sum = add i64 %j, %tmp + %arrayidx = getelementptr inbounds double* %A, i64 %vlaarrayidx.sum + store double 1.0, double* %arrayidx + %j.inc = add nsw i64 %j, 1 + %j.exitcond = icmp eq i64 %j.inc, %m + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: + %i.inc = add nsw i64 %i, 1 + %i.exitcond = icmp eq i64 %i.inc, %n + br i1 %i.exitcond, label %end, label %for.i + +end: + ret void +} diff --git a/test/Analysis/Delinearization/multidim_only_ivs_2d_nested.ll b/test/Analysis/Delinearization/multidim_only_ivs_2d_nested.ll new file mode 100644 index 0000000000000..7207420205aad --- /dev/null +++ b/test/Analysis/Delinearization/multidim_only_ivs_2d_nested.ll @@ -0,0 +1,78 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; extern void bar(long n, long m, double A[n][m]); +; +; void foo(long a, long b) { +; for (long n = 1; n < a; ++n) +; for (long m = 1; m < b; ++m) { +; double A[n][m]; +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; A[i][j] = 1.0; +; bar(n, m, A); +; } +; } + +; AddRec: {{%vla.us,+,{8,+,8}<%for.cond7.preheader.lr.ph.split.us.us>}<%for.body9.lr.ph.us.us>,+,8}<%for.body9.us.us> +; CHECK: Base offset: %vla.us +; CHECK: ArrayDecl[UnknownSize][{1,+,1}<%for.cond7.preheader.lr.ph.split.us.us>] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.body9.lr.ph.us.us>][{0,+,1}<nuw><nsw><%for.body9.us.us>] + +define void @foo(i64 %a, i64 %b) nounwind uwtable { +entry: + %cmp43 = icmp sgt i64 %a, 1 + br i1 %cmp43, label %for.cond1.preheader.lr.ph, label %for.end19 + +for.cond1.preheader.lr.ph: ; preds = %entry + %cmp224 = icmp sgt i64 %b, 1 + br label %for.cond1.preheader + +for.cond1.preheader: ; preds = %for.inc17, %for.cond1.preheader.lr.ph + %indvars.iv51 = phi i64 [ 1, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next52, %for.inc17 ] + br i1 %cmp224, label %for.cond7.preheader.lr.ph.split.us.us, label %for.inc17 + +for.end13.us: ; preds = %for.inc11.us.us + call void @bar(i64 %indvars.iv51, i64 %indvars.iv48, double* %vla.us) nounwind + call void @llvm.stackrestore(i8* %1) + %indvars.iv.next49 = add i64 %indvars.iv48, 1 + %exitcond54 = icmp eq i64 %indvars.iv.next49, %b + br i1 %exitcond54, label %for.inc17, label %for.cond7.preheader.lr.ph.split.us.us + +for.inc11.us.us: ; preds = %for.body9.us.us + %inc12.us.us = add nsw i64 %i.023.us.us, 1 + %exitcond53 = icmp eq i64 %inc12.us.us, %indvars.iv51 + br i1 %exitcond53, label %for.end13.us, label %for.body9.lr.ph.us.us + +for.body9.lr.ph.us.us: ; preds = %for.cond7.preheader.lr.ph.split.us.us, %for.inc11.us.us + %i.023.us.us = phi i64 [ 0, %for.cond7.preheader.lr.ph.split.us.us ], [ %inc12.us.us, %for.inc11.us.us ] + %0 = mul nsw i64 %i.023.us.us, %indvars.iv48 + br label %for.body9.us.us + +for.body9.us.us: ; preds = %for.body9.us.us, %for.body9.lr.ph.us.us + %j.021.us.us = phi i64 [ 0, %for.body9.lr.ph.us.us ], [ %inc.us.us, %for.body9.us.us ] + %arrayidx.sum.us.us = add i64 %j.021.us.us, %0 + %arrayidx10.us.us = getelementptr inbounds double* %vla.us, i64 %arrayidx.sum.us.us + store double 1.000000e+00, double* %arrayidx10.us.us, align 8 + %inc.us.us = add nsw i64 %j.021.us.us, 1 + %exitcond50 = icmp eq i64 %inc.us.us, %indvars.iv48 + br i1 %exitcond50, label %for.inc11.us.us, label %for.body9.us.us + +for.cond7.preheader.lr.ph.split.us.us: ; preds = %for.cond1.preheader, %for.end13.us + %indvars.iv48 = phi i64 [ %indvars.iv.next49, %for.end13.us ], [ 1, %for.cond1.preheader ] + %1 = call i8* @llvm.stacksave() + %2 = mul nuw i64 %indvars.iv48, %indvars.iv51 + %vla.us = alloca double, i64 %2, align 16 + br label %for.body9.lr.ph.us.us + +for.inc17: ; preds = %for.end13.us, %for.cond1.preheader + %indvars.iv.next52 = add i64 %indvars.iv51, 1 + %exitcond55 = icmp eq i64 %indvars.iv.next52, %a + br i1 %exitcond55, label %for.end19, label %for.cond1.preheader + +for.end19: ; preds = %for.inc17, %entry + ret void +} + +declare i8* @llvm.stacksave() nounwind +declare void @bar(i64, i64, double*) +declare void @llvm.stackrestore(i8*) nounwind diff --git a/test/Analysis/Delinearization/multidim_only_ivs_3d.ll b/test/Analysis/Delinearization/multidim_only_ivs_3d.ll new file mode 100644 index 0000000000000..24f95837c8607 --- /dev/null +++ b/test/Analysis/Delinearization/multidim_only_ivs_3d.ll @@ -0,0 +1,65 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s + +; void foo(long n, long m, long o, double A[n][m][o]) { +; +; for (long i = 0; i < n; i++) +; for (long j = 0; j < m; j++) +; for (long k = 0; k < o; k++) +; A[i][j][k] = 1.0; +; } + +; AddRec: {{{%A,+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j>,+,8}<%for.k> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>][{0,+,1}<nuw><nsw><%for.k>] + +; AddRec: {{(-8 + (8 * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][(%m * %o)] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{(-1 + %o),+,%o}<%for.j>] + +; AddRec: {(-8 + (8 * %m * %o) + %A),+,(8 * %m * %o)}<%for.i> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(double) bytes. +; CHECK: ArrayRef[{(-1 + (%m * %o)),+,(%m * %o)}<%for.i>] + +define void @foo(i64 %n, i64 %m, i64 %o, double* %A) { +entry: + br label %for.i + +for.i: + %i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ] + br label %for.j + +for.j: + %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ] + br label %for.k + +for.k: + %k = phi i64 [ 0, %for.j ], [ %k.inc, %for.k.inc ] + %subscript0 = mul i64 %i, %m + %subscript1 = add i64 %j, %subscript0 + %subscript2 = mul i64 %subscript1, %o + %subscript = add i64 %subscript2, %k + %idx = getelementptr inbounds double* %A, i64 %subscript + store double 1.0, double* %idx + br label %for.k.inc + +for.k.inc: + %k.inc = add nsw i64 %k, 1 + %k.exitcond = icmp eq i64 %k.inc, %o + br i1 %k.exitcond, label %for.j.inc, label %for.k + +for.j.inc: + %j.inc = add nsw i64 %j, 1 + %j.exitcond = icmp eq i64 %j.inc, %m + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: + %i.inc = add nsw i64 %i, 1 + %i.exitcond = icmp eq i64 %i.inc, %n + br i1 %i.exitcond, label %end, label %for.i + +end: + ret void +} diff --git a/test/Analysis/Delinearization/multidim_only_ivs_3d_cast.ll b/test/Analysis/Delinearization/multidim_only_ivs_3d_cast.ll new file mode 100644 index 0000000000000..e1516104ddfcb --- /dev/null +++ b/test/Analysis/Delinearization/multidim_only_ivs_3d_cast.ll @@ -0,0 +1,75 @@ +; RUN: opt < %s -analyze -delinearize | FileCheck %s +; void foo(int n, int m, int o, double A[n][m][o]) { +; +; for (int i = 0; i < n; i++) +; for (int j = 0; j < m; j++) +; for (int k = 0; k < o; k++) +; A[i][j][k] = 1.0; +; } + +; AddRec: {{{%A,+,(8 * (zext i32 %m to i64) * (zext i32 %o to i64))}<%for.i>,+,(8 * (zext i32 %o to i64))}<%for.j>,+,8}<%for.k> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][(zext i32 %m to i64)][(zext i32 %o to i64)] with elements of 8 bytes. +; CHECK: ArrayRef[{0,+,1}<%for.i>][{0,+,1}<%for.j>][{0,+,1}<%for.k>] + +; AddRec: {{((8 * (zext i32 (-1 + %o) to i64)) + %A),+,(8 * (zext i32 %m to i64) * (zext i32 %o to i64))}<%for.i>,+,(8 * (zext i32 %o to i64))}<%for.j> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize][((zext i32 %m to i64) * (zext i32 %o to i64))] with elements of 8 bytes. +; CHECK: ArrayRef[{0,+,1}<%for.i>][{(zext i32 (-1 + %o) to i64),+,(zext i32 %o to i64)}<%for.j>] + +; AddRec: {((8 * (zext i32 (-1 + %o) to i64)) + (8 * (zext i32 (-1 + %m) to i64) * (zext i32 %o to i64)) + %A),+,(8 * (zext i32 %m to i64) * (zext i32 %o to i64))}<%for.i> +; CHECK: Base offset: %A +; CHECK: ArrayDecl[UnknownSize] with elements of 8 bytes. +; CHECK: ArrayRef[{((zext i32 (-1 + %o) to i64) + ((zext i32 (-1 + %m) to i64) * (zext i32 %o to i64))),+,((zext i32 %m to i64) * (zext i32 %o to i64))}<%for.i>] + +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-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @foo(i32 %n, i32 %m, i32 %o, double* %A) { +entry: + %m_zext = zext i32 %m to i64 + %n_zext = zext i32 %o to i64 + br label %for.i + +for.i: + %i = phi i64 [ %i.inc, %for.i.inc ], [ 0, %entry ] + br label %for.j + +for.j: + %j = phi i64 [ %j.inc, %for.j.inc ], [ 0, %for.i ] + br label %for.k + +for.k: + %k = phi i64 [ %k.inc, %for.k.inc ], [ 0, %for.j ] + %tmp = mul i64 %i, %m_zext + %tmp1 = trunc i64 %j to i32 + %tmp2 = trunc i64 %i to i32 + %mul.us.us = mul nsw i32 %tmp1, %tmp2 + %tmp.us.us = add i64 %j, %tmp + %tmp17.us.us = mul i64 %tmp.us.us, %n_zext + %subscript = add i64 %tmp17.us.us, %k + %idx = getelementptr inbounds double* %A, i64 %subscript + store double 1.0, double* %idx + br label %for.k.inc + +for.k.inc: + %k.inc = add i64 %k, 1 + %k.inc.trunc = trunc i64 %k.inc to i32 + %k.exitcond = icmp eq i32 %k.inc.trunc, %o + br i1 %k.exitcond, label %for.j.inc, label %for.k + +for.j.inc: + %j.inc = add i64 %j, 1 + %j.inc.trunc = trunc i64 %j.inc to i32 + %j.exitcond = icmp eq i32 %j.inc.trunc, %m + br i1 %j.exitcond, label %for.i.inc, label %for.j + +for.i.inc: + %i.inc = add i64 %i, 1 + %i.inc.trunc = trunc i64 %i.inc to i32 + %i.exitcond = icmp eq i32 %i.inc.trunc, %n + br i1 %i.exitcond, label %end, label %for.i + +end: + ret void +} diff --git a/test/Analysis/DependenceAnalysis/Banerjee.ll b/test/Analysis/DependenceAnalysis/Banerjee.ll index 003ee03ab0be1..09e8fd29dcc42 100644 --- a/test/Analysis/DependenceAnalysis/Banerjee.ll +++ b/test/Analysis/DependenceAnalysis/Banerjee.ll @@ -13,7 +13,7 @@ target triple = "x86_64-apple-macosx10.6.0" define void @banerjee0(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader - +; CHECK: 'Dependence Analysis' for function 'banerjee0': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [<= <>]! ; CHECK: da analyze - confused! @@ -65,6 +65,7 @@ entry: %cmp4 = icmp sgt i64 %n, 0 br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end9 +; CHECK: 'Dependence Analysis' for function 'banerjee1': ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [* <>]! ; CHECK: da analyze - confused! @@ -131,6 +132,7 @@ define void @banerjee2(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee2': ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -181,6 +183,7 @@ define void @banerjee3(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee3': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [> >]! ; CHECK: da analyze - confused! @@ -231,6 +234,7 @@ define void @banerjee4(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee4': ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -281,6 +285,7 @@ define void @banerjee5(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee5': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [< <]! ; CHECK: da analyze - confused! @@ -331,6 +336,7 @@ define void @banerjee6(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee6': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [=> <>]! ; CHECK: da analyze - confused! @@ -381,6 +387,7 @@ define void @banerjee7(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee7': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [> <=]! ; CHECK: da analyze - confused! @@ -431,6 +438,7 @@ define void @banerjee8(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee8': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [> <>]! ; CHECK: da analyze - confused! @@ -481,6 +489,7 @@ define void @banerjee9(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee9': ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [<= =|<]! ; CHECK: da analyze - confused! @@ -532,6 +541,7 @@ define void @banerjee10(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee10': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [<> =]! ; CHECK: da analyze - confused! @@ -582,6 +592,7 @@ define void @banerjee11(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee11': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [<= <>]! ; CHECK: da analyze - confused! @@ -632,6 +643,7 @@ define void @banerjee12(i64* %A, i64* %B, i64 %m, i64 %n) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'banerjee12': ; CHECK: da analyze - none! ; CHECK: da analyze - flow [= <>]! ; CHECK: da analyze - confused! diff --git a/test/Analysis/DependenceAnalysis/GCD.ll b/test/Analysis/DependenceAnalysis/GCD.ll index a42212464f866..bb31d118857d6 100644 --- a/test/Analysis/DependenceAnalysis/GCD.ll +++ b/test/Analysis/DependenceAnalysis/GCD.ll @@ -14,6 +14,7 @@ define void @gcd0(i32* %A, i32* %B) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'gcd0' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [=> *|<]! ; CHECK: da analyze - confused! @@ -66,6 +67,7 @@ define void @gcd1(i32* %A, i32* %B) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'gcd1' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -119,6 +121,7 @@ define void @gcd2(i32* %A, i32* %B) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'gcd2' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -172,6 +175,7 @@ define void @gcd3(i32* %A, i32* %B) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'gcd3' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [<> *]! ; CHECK: da analyze - confused! @@ -223,6 +227,7 @@ define void @gcd4(i32* %A, i32* %B, i64 %M, i64 %N) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'gcd4' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -284,6 +289,7 @@ define void @gcd5(i32* %A, i32* %B, i64 %M, i64 %N) nounwind uwtable ssp { entry: br label %for.cond1.preheader +; CHECK: 'Dependence Analysis' for function 'gcd5' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [<> *]! ; CHECK: da analyze - confused! @@ -346,6 +352,7 @@ entry: %cmp4 = icmp sgt i64 %n, 0 br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end12 +; CHECK: 'Dependence Analysis' for function 'gcd6' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -417,6 +424,7 @@ entry: %cmp4 = icmp sgt i32 %n, 0 br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end15 +; CHECK: 'Dependence Analysis' for function 'gcd7' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [* *|<]! ; CHECK: da analyze - confused! @@ -500,6 +508,7 @@ entry: %cmp4 = icmp sgt i32 %n, 0 br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end15 +; CHECK: 'Dependence Analysis' for function 'gcd8' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -578,6 +587,7 @@ entry: %cmp4 = icmp eq i32 %n, 0 br i1 %cmp4, label %for.end15, label %for.cond1.preheader.preheader +; CHECK: 'Dependence Analysis' for function 'gcd9' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - flow [* *|<]! ; CHECK: da analyze - confused! diff --git a/test/Analysis/DependenceAnalysis/Invariant.ll b/test/Analysis/DependenceAnalysis/Invariant.ll new file mode 100644 index 0000000000000..202d8e2d68db1 --- /dev/null +++ b/test/Analysis/DependenceAnalysis/Invariant.ll @@ -0,0 +1,40 @@ +; RUN: opt < %s -analyze -basicaa -da | FileCheck %s + +; Test for a bug, which caused an assert when an invalid +; SCEVAddRecExpr is created in addToCoefficient. + +; CHECK: da analyze - consistent input [S 0]! +; CHECK: da analyze - input [* 0|<]! +; CHECK: da analyze - none! + +define float @foo(float %g, [40 x float]* %rr) nounwind { +entry: + br label %for.cond1.preheader + +for.cond1.preheader: + %i.04 = phi i32 [ 0, %entry ], [ %add10, %for.inc9 ] + %res.03 = phi float [ 0.000000e+00, %entry ], [ %add.res.1, %for.inc9 ] + br label %for.body3 + +for.body3: + %j.02 = phi i32 [ 0, %for.cond1.preheader ], [ %add8, %for.body3 ] + %res.11 = phi float [ %res.03, %for.cond1.preheader ], [ %add.res.1, %for.body3 ] + %arrayidx4 = getelementptr inbounds [40 x float]* %rr, i32 %j.02, i32 %j.02 + %0 = load float* %arrayidx4, align 4 + %arrayidx6 = getelementptr inbounds [40 x float]* %rr, i32 %i.04, i32 %j.02 + %1 = load float* %arrayidx6, align 4 + %add = fadd float %0, %1 + %cmp7 = fcmp ogt float %add, %g + %add.res.1 = select i1 %cmp7, float %add, float %res.11 + %add8 = add nsw i32 %j.02, 5 + %cmp2 = icmp slt i32 %add8, 40 + br i1 %cmp2, label %for.body3, label %for.inc9 + +for.inc9: + %add10 = add nsw i32 %i.04, 5 + %cmp = icmp slt i32 %add10, 40 + br i1 %cmp, label %for.cond1.preheader, label %for.end11 + +for.end11: + ret float %add.res.1 +} diff --git a/test/Analysis/DependenceAnalysis/SymbolicRDIV.ll b/test/Analysis/DependenceAnalysis/SymbolicRDIV.ll index 81e61892d8e8d..5443909d7ef66 100644 --- a/test/Analysis/DependenceAnalysis/SymbolicRDIV.ll +++ b/test/Analysis/DependenceAnalysis/SymbolicRDIV.ll @@ -15,6 +15,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv0' ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -77,6 +78,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.cond2.preheader, label %for.body.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv1' ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -141,6 +143,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv2' ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -203,6 +206,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv3' ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -263,6 +267,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv4' ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -324,6 +329,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv5' ; CHECK: da analyze - none! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! @@ -385,6 +391,7 @@ entry: %cmp4 = icmp eq i64 %n1, 0 br i1 %cmp4, label %for.end7, label %for.cond1.preheader.preheader +; CHECK: 'Dependence Analysis' for function 'symbolicrdiv6' ; CHECK: da analyze - output [* *]! ; CHECK: da analyze - none! ; CHECK: da analyze - confused! diff --git a/test/Analysis/Dominators/lit.local.cfg b/test/Analysis/Dominators/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/Dominators/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/GlobalsModRef/lit.local.cfg b/test/Analysis/GlobalsModRef/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/GlobalsModRef/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/Lint/check-zero-divide.ll b/test/Analysis/Lint/check-zero-divide.ll new file mode 100644 index 0000000000000..f4e79ed95f8c3 --- /dev/null +++ b/test/Analysis/Lint/check-zero-divide.ll @@ -0,0 +1,78 @@ +; RUN: opt -lint -disable-output %s 2>&1 | FileCheck %s + +define <2 x i32> @use_vector_sdiv(<2 x i32> %a) nounwind { + %b = sdiv <2 x i32> %a, <i32 5, i32 8> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_srem(<2 x i32> %a) nounwind { + %b = srem <2 x i32> %a, <i32 5, i32 8> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_udiv(<2 x i32> %a) nounwind { + %b = udiv <2 x i32> %a, <i32 5, i32 8> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_urem(<2 x i32> %a) nounwind { + %b = urem <2 x i32> %a, <i32 5, i32 8> + ret <2 x i32> %b +} + +define i32 @use_sdiv_by_zero(i32 %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv i32 %a, 0 + %b = sdiv i32 %a, 0 + ret i32 %b +} + +define i32 @use_sdiv_by_zeroinitializer(i32 %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv i32 %a, 0 + %b = sdiv i32 %a, zeroinitializer + ret i32 %b +} + +define <2 x i32> @use_vector_sdiv_by_zero_x(<2 x i32> %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 0, i32 5> + %b = sdiv <2 x i32> %a, <i32 0, i32 5> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_sdiv_by_zero_y(<2 x i32> %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 4, i32 0> + %b = sdiv <2 x i32> %a, <i32 4, i32 0> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_sdiv_by_zero_xy(<2 x i32> %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv <2 x i32> %a, zeroinitializer + %b = sdiv <2 x i32> %a, <i32 0, i32 0> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_sdiv_by_undef_x(<2 x i32> %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 undef, i32 5> + %b = sdiv <2 x i32> %a, <i32 undef, i32 5> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_sdiv_by_undef_y(<2 x i32> %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 5, i32 undef> + %b = sdiv <2 x i32> %a, <i32 5, i32 undef> + ret <2 x i32> %b +} + +define <2 x i32> @use_vector_sdiv_by_undef_xy(<2 x i32> %a) nounwind { +; CHECK: Undefined behavior: Division by zero +; CHECK-NEXT: %b = sdiv <2 x i32> %a, undef + %b = sdiv <2 x i32> %a, <i32 undef, i32 undef> + ret <2 x i32> %b +} + diff --git a/test/Analysis/DependenceAnalysis/lit.local.cfg b/test/Analysis/Lint/lit.local.cfg index c6106e4746f2d..c6106e4746f2d 100644 --- a/test/Analysis/DependenceAnalysis/lit.local.cfg +++ b/test/Analysis/Lint/lit.local.cfg diff --git a/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll b/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll index 7119007ffde51..a87bab7cabf23 100644 --- a/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll +++ b/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll @@ -1,8 +1,9 @@ ; This testcase was incorrectly computing that the loopentry.7 loop was ; not a child of the loopentry.6 loop. ; -; RUN: opt < %s -analyze -loops | \ -; RUN: grep "^ Loop at depth 4 containing: %loopentry.7<header><latch><exiting>" +; RUN: opt < %s -analyze -loops | FileCheck %s + +; CHECK: Loop at depth 4 containing: %loopentry.7<header><latch><exiting> define void @getAndMoveToFrontDecode() { br label %endif.2 diff --git a/test/Analysis/LoopInfo/lit.local.cfg b/test/Analysis/LoopInfo/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/LoopInfo/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/MemoryDependenceAnalysis/lit.local.cfg b/test/Analysis/MemoryDependenceAnalysis/lit.local.cfg deleted file mode 100644 index c6106e4746f2d..0000000000000 --- a/test/Analysis/MemoryDependenceAnalysis/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll'] diff --git a/test/Analysis/PostDominators/lit.local.cfg b/test/Analysis/PostDominators/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/PostDominators/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/PostDominators/pr1098.ll b/test/Analysis/PostDominators/pr1098.ll index afb47769ee498..2eed21371276e 100644 --- a/test/Analysis/PostDominators/pr1098.ll +++ b/test/Analysis/PostDominators/pr1098.ll @@ -1,7 +1,8 @@ -; RUN: opt < %s -postdomtree -analyze | grep entry +; RUN: opt < %s -postdomtree -analyze | FileCheck %s ; PR932 define void @foo(i1 %x) { +; CHECK: entry entry: br i1 %x, label %bb1, label %bb0 bb0: ; preds = %entry, bb0 diff --git a/test/Analysis/Profiling/edge-profiling.ll b/test/Analysis/Profiling/edge-profiling.ll deleted file mode 100644 index cbaf47617fb6c..0000000000000 --- a/test/Analysis/Profiling/edge-profiling.ll +++ /dev/null @@ -1,139 +0,0 @@ -; Test the edge profiling instrumentation. -; RUN: opt < %s -insert-edge-profiling -S | FileCheck %s - -; ModuleID = '<stdin>' - -@.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1] -@.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1] -@.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1] -@.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1] -@.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1] -@.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1] -; CHECK:@EdgeProfCounters -; CHECK:[19 x i32] -; CHECK:zeroinitializer - -define void @oneblock() nounwind { -entry: -; CHECK:entry: -; CHECK:%OldFuncCounter -; CHECK:load -; CHECK:getelementptr -; CHECK:@EdgeProfCounters -; CHECK:i32 0 -; CHECK:i32 0 -; CHECK:%NewFuncCounter -; CHECK:add -; CHECK:%OldFuncCounter -; CHECK:store -; CHECK:%NewFuncCounter -; CHECK:getelementptr -; CHECK:@EdgeProfCounters - %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - ret void -} - -declare i32 @puts(i8*) - -define i32 @main(i32 %argc, i8** %argv) nounwind { -entry: -; CHECK:entry: - %argc_addr = alloca i32 ; <i32*> [#uses=4] - %argv_addr = alloca i8** ; <i8***> [#uses=1] - %retval = alloca i32 ; <i32*> [#uses=2] - %j = alloca i32 ; <i32*> [#uses=4] - %i = alloca i32 ; <i32*> [#uses=4] - %0 = alloca i32 ; <i32*> [#uses=2] -; CHECK:call -; CHECK:@llvm_start_edge_profiling -; CHECK:@EdgeProfCounters - %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] - store i32 %argc, i32* %argc_addr - store i8** %argv, i8*** %argv_addr - store i32 0, i32* %i, align 4 - br label %bb10 - -bb: ; preds = %bb10 -; CHECK:bb: - %1 = load i32* %argc_addr, align 4 ; <i32> [#uses=1] - %2 = icmp sgt i32 %1, 1 ; <i1> [#uses=1] - br i1 %2, label %bb1, label %bb8 - -bb1: ; preds = %bb -; CHECK:bb1: - store i32 0, i32* %j, align 4 - br label %bb6 - -bb2: ; preds = %bb6 -; CHECK:bb2: - %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - %4 = load i32* %argc_addr, align 4 ; <i32> [#uses=1] - %5 = icmp sgt i32 %4, 2 ; <i1> [#uses=1] - br i1 %5, label %bb3, label %bb4 - -bb3: ; preds = %bb2 -; CHECK:bb3: - %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - br label %bb5 - -bb4: ; preds = %bb2 -; CHECK:bb4: - %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - br label %bb11 - -bb5: ; preds = %bb3 -; CHECK:bb5: - %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - %9 = load i32* %j, align 4 ; <i32> [#uses=1] - %10 = add nsw i32 %9, 1 ; <i32> [#uses=1] - store i32 %10, i32* %j, align 4 - br label %bb6 - -bb6: ; preds = %bb5, %bb1 -; CHECK:bb6: - %11 = load i32* %j, align 4 ; <i32> [#uses=1] - %12 = load i32* %argc_addr, align 4 ; <i32> [#uses=1] - %13 = icmp slt i32 %11, %12 ; <i1> [#uses=1] - br i1 %13, label %bb2, label %bb7 - -bb7: ; preds = %bb6 -; CHECK:bb7: - br label %bb9 - -bb8: ; preds = %bb -; CHECK:bb8: - %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - br label %bb9 - -bb9: ; preds = %bb8, %bb7 -; CHECK:bb9: - %15 = load i32* %i, align 4 ; <i32> [#uses=1] - %16 = add nsw i32 %15, 1 ; <i32> [#uses=1] - store i32 %16, i32* %i, align 4 - br label %bb10 - -bb10: ; preds = %bb9, %entry -; CHECK:bb10: - %17 = load i32* %i, align 4 ; <i32> [#uses=1] - %18 = icmp ne i32 %17, 3 ; <i1> [#uses=1] - br i1 %18, label %bb, label %bb11 -; CHECK:br -; CHECK:label %bb10.bb11_crit_edge - -; CHECK:bb10.bb11_crit_edge: -; CHECK:br -; CHECK:label %bb11 - -bb11: ; preds = %bb10, %bb4 -; CHECK:bb11: - call void @oneblock() nounwind - store i32 0, i32* %0, align 4 - %19 = load i32* %0, align 4 ; <i32> [#uses=1] - store i32 %19, i32* %retval, align 4 - br label %return - -return: ; preds = %bb11 -; CHECK:return: - %retval12 = load i32* %retval ; <i32> [#uses=1] - ret i32 %retval12 -} diff --git a/test/Analysis/Profiling/lit.local.cfg b/test/Analysis/Profiling/lit.local.cfg deleted file mode 100644 index d40fa4f9d3abd..0000000000000 --- a/test/Analysis/Profiling/lit.local.cfg +++ /dev/null @@ -1,11 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] - -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if 'hexagon' in root.target_triple: - config.unsupported = True diff --git a/test/Analysis/Profiling/load-branch-weights-ifs.ll b/test/Analysis/Profiling/load-branch-weights-ifs.ll deleted file mode 100644 index 7ed090b7c366a..0000000000000 --- a/test/Analysis/Profiling/load-branch-weights-ifs.ll +++ /dev/null @@ -1,122 +0,0 @@ -; RUN: opt -insert-edge-profiling -o %t1 < %s -; RUN: rm -f %t1.prof_data -; RUN: lli %defaultjit -load %llvmshlibdir/libprofile_rt%shlibext %t1 \ -; RUN: -llvmprof-output %t1.prof_data -; RUN: opt -profile-file %t1.prof_data -profile-metadata-loader -S -o - < %s \ -; RUN: | FileCheck %s -; RUN: rm -f %t1.prof_data - -; FIXME: profile_rt.dll could be built on win32. -; REQUIRES: loadable_module - -;; func_mod - Branch taken 6 times in 7. -define i32 @func_mod(i32 %N) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %N.addr = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - %0 = load i32* %N.addr, align 4 - %rem = srem i32 %0, 7 - %tobool = icmp ne i32 %rem, 0 - br i1 %tobool, label %if.then, label %if.else -; CHECK: br i1 %tobool, label %if.then, label %if.else, !prof !0 - -if.then: - store i32 1, i32* %retval - br label %return - -if.else: - store i32 0, i32* %retval - br label %return - -return: - %1 = load i32* %retval - ret i32 %1 -} - -;; func_const_true - conditional branch which 100% taken probability. -define i32 @func_const_true(i32 %N) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %N.addr = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - %0 = load i32* %N.addr, align 4 - %cmp = icmp eq i32 %0, 1 - br i1 %cmp, label %if.then, label %if.end -; CHECK: br i1 %cmp, label %if.then, label %if.end, !prof !1 - -if.then: - store i32 1, i32* %retval - br label %return - -if.end: - store i32 0, i32* %retval - br label %return - -return: - %1 = load i32* %retval - ret i32 %1 -} - -;; func_const_true - conditional branch which 100% not-taken probability. -define i32 @func_const_false(i32 %N) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %N.addr = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - %0 = load i32* %N.addr, align 4 - %cmp = icmp eq i32 %0, 1 - br i1 %cmp, label %if.then, label %if.end -; CHECK: br i1 %cmp, label %if.then, label %if.end, !prof !2 - -if.then: - store i32 1, i32* %retval - br label %return - -if.end: - store i32 0, i32* %retval - br label %return - -return: - %1 = load i32* %retval - ret i32 %1 -} - -define i32 @main(i32 %argc, i8** %argv) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %argc.addr = alloca i32, align 4 - %argv.addr = alloca i8**, align 8 - %loop = alloca i32, align 4 - store i32 0, i32* %retval - store i32 0, i32* %loop, align 4 - br label %for.cond - -for.cond: - %0 = load i32* %loop, align 4 - %cmp = icmp slt i32 %0, 7000 - br i1 %cmp, label %for.body, label %for.end -; CHECK: br i1 %cmp, label %for.body, label %for.end, !prof !3 - -for.body: - %1 = load i32* %loop, align 4 - %call = call i32 @func_mod(i32 %1) - br label %for.inc - -for.inc: - %2 = load i32* %loop, align 4 - %inc = add nsw i32 %2, 1 - store i32 %inc, i32* %loop, align 4 - br label %for.cond - -for.end: - %call1 = call i32 @func_const_true(i32 1) - %call2 = call i32 @func_const_false(i32 0) - ret i32 0 -} - -; CHECK: !0 = metadata !{metadata !"branch_weights", i32 6000, i32 1000} -; CHECK: !1 = metadata !{metadata !"branch_weights", i32 1, i32 0} -; CHECK: !2 = metadata !{metadata !"branch_weights", i32 0, i32 1} -; CHECK: !3 = metadata !{metadata !"branch_weights", i32 7000, i32 1} -; CHECK-NOT: !4 diff --git a/test/Analysis/Profiling/load-branch-weights-loops.ll b/test/Analysis/Profiling/load-branch-weights-loops.ll deleted file mode 100644 index 9d1925a2d7016..0000000000000 --- a/test/Analysis/Profiling/load-branch-weights-loops.ll +++ /dev/null @@ -1,188 +0,0 @@ -; RUN: opt -insert-edge-profiling -o %t1 < %s -; RUN: rm -f %t1.prof_data -; RUN: lli %defaultjit -load %llvmshlibdir/libprofile_rt%shlibext %t1 \ -; RUN: -llvmprof-output %t1.prof_data -; RUN: opt -profile-file %t1.prof_data -profile-metadata-loader -S -o - < %s \ -; RUN: | FileCheck %s -; RUN: rm -f %t1.prof_data - -; FIXME: profile_rt.dll could be built on win32. -; REQUIRES: loadable_module - -;; func_for - Test branch probabilities for a vanilla for loop. -define i32 @func_for(i32 %N) nounwind uwtable { -entry: - %N.addr = alloca i32, align 4 - %ret = alloca i32, align 4 - %loop = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - store i32 0, i32* %ret, align 4 - store i32 0, i32* %loop, align 4 - br label %for.cond - -for.cond: - %0 = load i32* %loop, align 4 - %1 = load i32* %N.addr, align 4 - %cmp = icmp slt i32 %0, %1 - br i1 %cmp, label %for.body, label %for.end -; CHECK: br i1 %cmp, label %for.body, label %for.end, !prof !0 - -for.body: - %2 = load i32* %N.addr, align 4 - %3 = load i32* %ret, align 4 - %add = add nsw i32 %3, %2 - store i32 %add, i32* %ret, align 4 - br label %for.inc - -for.inc: - %4 = load i32* %loop, align 4 - %inc = add nsw i32 %4, 1 - store i32 %inc, i32* %loop, align 4 - br label %for.cond - -for.end: - %5 = load i32* %ret, align 4 - ret i32 %5 -} - -;; func_for_odd - Test branch probabilities for a for loop with a continue and -;; a break. -define i32 @func_for_odd(i32 %N) nounwind uwtable { -entry: - %N.addr = alloca i32, align 4 - %ret = alloca i32, align 4 - %loop = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - store i32 0, i32* %ret, align 4 - store i32 0, i32* %loop, align 4 - br label %for.cond - -for.cond: - %0 = load i32* %loop, align 4 - %1 = load i32* %N.addr, align 4 - %cmp = icmp slt i32 %0, %1 - br i1 %cmp, label %for.body, label %for.end -; CHECK: br i1 %cmp, label %for.body, label %for.end, !prof !1 - -for.body: - %2 = load i32* %loop, align 4 - %rem = srem i32 %2, 10 - %tobool = icmp ne i32 %rem, 0 - br i1 %tobool, label %if.then, label %if.end -; CHECK: br i1 %tobool, label %if.then, label %if.end, !prof !2 - -if.then: - br label %for.inc - -if.end: - %3 = load i32* %loop, align 4 - %cmp1 = icmp eq i32 %3, 500 - br i1 %cmp1, label %if.then2, label %if.end3 -; CHECK: br i1 %cmp1, label %if.then2, label %if.end3, !prof !3 - -if.then2: - br label %for.end - -if.end3: - %4 = load i32* %N.addr, align 4 - %5 = load i32* %ret, align 4 - %add = add nsw i32 %5, %4 - store i32 %add, i32* %ret, align 4 - br label %for.inc - -for.inc: - %6 = load i32* %loop, align 4 - %inc = add nsw i32 %6, 1 - store i32 %inc, i32* %loop, align 4 - br label %for.cond - -for.end: - %7 = load i32* %ret, align 4 - ret i32 %7 -} - -;; func_while - Test branch probability in a vanilla while loop. -define i32 @func_while(i32 %N) nounwind uwtable { -entry: - %N.addr = alloca i32, align 4 - %ret = alloca i32, align 4 - %loop = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - store i32 0, i32* %ret, align 4 - store i32 0, i32* %loop, align 4 - br label %while.cond - -while.cond: - %0 = load i32* %loop, align 4 - %1 = load i32* %N.addr, align 4 - %cmp = icmp slt i32 %0, %1 - br i1 %cmp, label %while.body, label %while.end -; CHECK: br i1 %cmp, label %while.body, label %while.end, !prof !0 - -while.body: - %2 = load i32* %N.addr, align 4 - %3 = load i32* %ret, align 4 - %add = add nsw i32 %3, %2 - store i32 %add, i32* %ret, align 4 - %4 = load i32* %loop, align 4 - %inc = add nsw i32 %4, 1 - store i32 %inc, i32* %loop, align 4 - br label %while.cond - -while.end: - %5 = load i32* %ret, align 4 - ret i32 %5 -} - -;; func_while - Test branch probability in a vanilla do-while loop. -define i32 @func_do_while(i32 %N) nounwind uwtable { -entry: - %N.addr = alloca i32, align 4 - %ret = alloca i32, align 4 - %loop = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - store i32 0, i32* %ret, align 4 - store i32 0, i32* %loop, align 4 - br label %do.body - -do.body: - %0 = load i32* %N.addr, align 4 - %1 = load i32* %ret, align 4 - %add = add nsw i32 %1, %0 - store i32 %add, i32* %ret, align 4 - %2 = load i32* %loop, align 4 - %inc = add nsw i32 %2, 1 - store i32 %inc, i32* %loop, align 4 - br label %do.cond - -do.cond: - %3 = load i32* %loop, align 4 - %4 = load i32* %N.addr, align 4 - %cmp = icmp slt i32 %3, %4 - br i1 %cmp, label %do.body, label %do.end -; CHECK: br i1 %cmp, label %do.body, label %do.end, !prof !4 - -do.end: - %5 = load i32* %ret, align 4 - ret i32 %5 -} - -define i32 @main(i32 %argc, i8** %argv) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %argc.addr = alloca i32, align 4 - %argv.addr = alloca i8**, align 8 - store i32 0, i32* %retval - %call = call i32 @func_for(i32 1000) - %call1 = call i32 @func_for_odd(i32 1000) - %call2 = call i32 @func_while(i32 1000) - %call3 = call i32 @func_do_while(i32 1000) - ret i32 0 -} - -!0 = metadata !{metadata !"branch_weights", i32 1000, i32 1} -!1 = metadata !{metadata !"branch_weights", i32 501, i32 0} -!2 = metadata !{metadata !"branch_weights", i32 450, i32 51} -!3 = metadata !{metadata !"branch_weights", i32 1, i32 50} -!4 = metadata !{metadata !"branch_weights", i32 999, i32 1} -; CHECK-NOT: !5 diff --git a/test/Analysis/Profiling/load-branch-weights-switches.ll b/test/Analysis/Profiling/load-branch-weights-switches.ll deleted file mode 100644 index 5587c7172bb6c..0000000000000 --- a/test/Analysis/Profiling/load-branch-weights-switches.ll +++ /dev/null @@ -1,165 +0,0 @@ -; RUN: opt -insert-edge-profiling -o %t1 < %s -; RUN: rm -f %t1.prof_data -; RUN: lli %defaultjit -load %llvmshlibdir/libprofile_rt%shlibext %t1 \ -; RUN: -llvmprof-output %t1.prof_data -; RUN: opt -profile-file %t1.prof_data -profile-metadata-loader -S -o - < %s \ -; RUN: | FileCheck %s -; RUN: rm -f %t1.prof_data - -; FIXME: profile_rt.dll could be built on win32. -; REQUIRES: loadable_module - -;; func_switch - Test branch probabilities for a switch instruction with an -;; even chance of taking each case (or no case). -define i32 @func_switch(i32 %N) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %N.addr = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - %0 = load i32* %N.addr, align 4 - %rem = srem i32 %0, 4 - switch i32 %rem, label %sw.epilog [ - i32 0, label %sw.bb - i32 1, label %sw.bb1 - i32 2, label %sw.bb2 - ] -; CHECK: ], !prof !0 - -sw.bb: - store i32 5, i32* %retval - br label %return - -sw.bb1: - store i32 6, i32* %retval - br label %return - -sw.bb2: - store i32 7, i32* %retval - br label %return - -sw.epilog: - store i32 8, i32* %retval - br label %return - -return: - %1 = load i32* %retval - ret i32 %1 -} - -;; func_switch_switch - Test branch probabilities in a switch-instruction that -;; leads to further switch instructions. The first-tier switch occludes some -;; possibilities in the second-tier switches, leading to some branches having a -;; 0 probability. -define i32 @func_switch_switch(i32 %N) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %N.addr = alloca i32, align 4 - store i32 %N, i32* %N.addr, align 4 - %0 = load i32* %N.addr, align 4 - %rem = srem i32 %0, 2 - switch i32 %rem, label %sw.default11 [ - i32 0, label %sw.bb - i32 1, label %sw.bb5 - ] -; CHECK: ], !prof !1 - -sw.bb: - %1 = load i32* %N.addr, align 4 - %rem1 = srem i32 %1, 4 - switch i32 %rem1, label %sw.default [ - i32 0, label %sw.bb2 - i32 1, label %sw.bb3 - i32 2, label %sw.bb4 - ] -; CHECK: ], !prof !2 - -sw.bb2: - store i32 5, i32* %retval - br label %return - -sw.bb3: - store i32 6, i32* %retval - br label %return - -sw.bb4: - store i32 7, i32* %retval - br label %return - -sw.default: - store i32 8, i32* %retval - br label %return - -sw.bb5: - %2 = load i32* %N.addr, align 4 - %rem6 = srem i32 %2, 4 - switch i32 %rem6, label %sw.default10 [ - i32 0, label %sw.bb7 - i32 1, label %sw.bb8 - i32 2, label %sw.bb9 - ] -; CHECK: ], !prof !3 - -sw.bb7: - store i32 9, i32* %retval - br label %return - -sw.bb8: - store i32 10, i32* %retval - br label %return - -sw.bb9: - store i32 11, i32* %retval - br label %return - -sw.default10: - store i32 12, i32* %retval - br label %return - -sw.default11: - store i32 13, i32* %retval - br label %return - -return: - %3 = load i32* %retval - ret i32 %3 -} - -define i32 @main(i32 %argc, i8** %argv) nounwind uwtable { -entry: - %retval = alloca i32, align 4 - %argc.addr = alloca i32, align 4 - %argv.addr = alloca i8**, align 8 - %loop = alloca i32, align 4 - store i32 0, i32* %retval - store i32 0, i32* %loop, align 4 - br label %for.cond - -for.cond: - %0 = load i32* %loop, align 4 - %cmp = icmp slt i32 %0, 4000 - br i1 %cmp, label %for.body, label %for.end -; CHECK: br i1 %cmp, label %for.body, label %for.end, !prof !4 - -for.body: - %1 = load i32* %loop, align 4 - %call = call i32 @func_switch(i32 %1) - %2 = load i32* %loop, align 4 - %call1 = call i32 @func_switch_switch(i32 %2) - br label %for.inc - -for.inc: - %3 = load i32* %loop, align 4 - %inc = add nsw i32 %3, 1 - store i32 %inc, i32* %loop, align 4 - br label %for.cond - -for.end: - ret i32 0 -} - -; CHECK: !0 = metadata !{metadata !"branch_weights", i32 1000, i32 1000, i32 1000, i32 1000} -; CHECK: !1 = metadata !{metadata !"branch_weights", i32 0, i32 2000, i32 2000} -; CHECK: !2 = metadata !{metadata !"branch_weights", i32 0, i32 1000, i32 0, i32 1000} -; CHECK: !3 = metadata !{metadata !"branch_weights", i32 1000, i32 0, i32 1000, i32 0} -; CHECK: !4 = metadata !{metadata !"branch_weights", i32 4000, i32 1} -; CHECK-NOT: !5 diff --git a/test/Analysis/Profiling/profiling-tool-chain.ll b/test/Analysis/Profiling/profiling-tool-chain.ll deleted file mode 100644 index 9135a85dc3ad4..0000000000000 --- a/test/Analysis/Profiling/profiling-tool-chain.ll +++ /dev/null @@ -1,212 +0,0 @@ -; RUN: llvm-as %s -o %t1 - -; FIXME: The RUX parts of the test are disabled for now, they aren't working on -; llvm-gcc-x86_64-darwin10-selfhost. - -; Test the edge optimal profiling instrumentation. -; RUN: opt %t1 -insert-optimal-edge-profiling -o %t2 -; RUX: llvm-dis < %t2 | FileCheck --check-prefix=INST %s - -; Test the creation, reading and displaying of profile -; RUX: rm -f llvmprof.out -; RUX: lli -load %llvmshlibdir/profile_rt%shlibext %t2 -; RUX: lli -load %llvmshlibdir/profile_rt%shlibext %t2 1 2 -; RUX: llvm-prof -print-all-code %t1 | FileCheck --check-prefix=PROF %s - -; Test the loaded profile also with verifier. -; RUX opt %t1 -profile-loader -profile-verifier -o %t3 - -; Test profile estimator. -; RUN: opt %t1 -profile-estimator -profile-verifier -o %t3 - -; PROF: 1. 2/4 oneblock -; PROF: 2. 2/4 main -; PROF: 1. 15.7895% 12/76 main() - bb6 -; PROF: 2. 11.8421% 9/76 main() - bb2 -; PROF: 3. 11.8421% 9/76 main() - bb3 -; PROF: 4. 11.8421% 9/76 main() - bb5 -; PROF: 5. 10.5263% 8/76 main() - bb10 -; PROF: 6. 7.89474% 6/76 main() - bb -; PROF: 7. 7.89474% 6/76 main() - bb9 -; PROF: 8. 3.94737% 3/76 main() - bb1 -; PROF: 9. 3.94737% 3/76 main() - bb7 -; PROF: 10. 3.94737% 3/76 main() - bb8 -; PROF: 11. 2.63158% 2/76 oneblock() - entry -; PROF: 12. 2.63158% 2/76 main() - entry -; PROF: 13. 2.63158% 2/76 main() - bb11 -; PROF: 14. 2.63158% 2/76 main() - return - -; ModuleID = '<stdin>' - -@.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1] -@.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1] -@.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1] -@.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1] -@.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1] -@.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1] -; INST:@OptEdgeProfCounters -; INST:[21 x i32] -; INST:[i32 0, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 0, -; INST:i32 0, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 0, -; INST:i32 0, -; INST:i32 -1, -; INST:i32 -1, -; INST:i32 0, -; INST:i32 -1, -; INST:i32 -1] - -; PROF:;;; %oneblock called 2 times. -; PROF:;;; -define void @oneblock() nounwind { -entry: -; PROF:entry: -; PROF: ;;; Basic block executed 2 times. - %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - ret void -} - -declare i32 @puts(i8*) - -; PROF:;;; %main called 2 times. -; PROF:;;; -define i32 @main(i32 %argc, i8** %argv) nounwind { -entry: -; PROF:entry: -; PROF: ;;; Basic block executed 2 times. - %argc_addr = alloca i32 ; <i32*> [#uses=4] - %argv_addr = alloca i8** ; <i8***> [#uses=1] - %retval = alloca i32 ; <i32*> [#uses=2] - %j = alloca i32 ; <i32*> [#uses=4] - %i = alloca i32 ; <i32*> [#uses=4] - %0 = alloca i32 ; <i32*> [#uses=2] -; INST:call -; INST:@llvm_start_opt_edge_profiling -; INST:@OptEdgeProfCounters - %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] - store i32 %argc, i32* %argc_addr - store i8** %argv, i8*** %argv_addr - store i32 0, i32* %i, align 4 - br label %bb10 -; PROF: ;;; Out-edge counts: [2.000000e+00 -> bb10] - -bb: ; preds = %bb10 -; PROF:bb: -; PROF: ;;; Basic block executed 6 times. - %1 = load i32* %argc_addr, align 4 ; <i32> [#uses=1] - %2 = icmp sgt i32 %1, 1 ; <i1> [#uses=1] - br i1 %2, label %bb1, label %bb8 -; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb1] [3.000000e+00 -> bb8] - -bb1: ; preds = %bb -; PROF:bb1: -; PROF: ;;; Basic block executed 3 times. - store i32 0, i32* %j, align 4 - br label %bb6 -; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb6] - -bb2: ; preds = %bb6 -; PROF:bb2: -; PROF: ;;; Basic block executed 9 times. - %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - %4 = load i32* %argc_addr, align 4 ; <i32> [#uses=1] - %5 = icmp sgt i32 %4, 2 ; <i1> [#uses=1] - br i1 %5, label %bb3, label %bb4 -; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb3] - -bb3: ; preds = %bb2 -; PROF:bb3: -; PROF: ;;; Basic block executed 9 times. - %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - br label %bb5 -; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb5] - -bb4: ; preds = %bb2 -; PROF:bb4: -; PROF: ;;; Never executed! - %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - br label %bb11 - -bb5: ; preds = %bb3 -; PROF:bb5: -; PROF: ;;; Basic block executed 9 times. - %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - %9 = load i32* %j, align 4 ; <i32> [#uses=1] - %10 = add nsw i32 %9, 1 ; <i32> [#uses=1] - store i32 %10, i32* %j, align 4 - br label %bb6 -; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb6] - -bb6: ; preds = %bb5, %bb1 -; PROF:bb6: -; PROF: ;;; Basic block executed 12 times. - %11 = load i32* %j, align 4 ; <i32> [#uses=1] - %12 = load i32* %argc_addr, align 4 ; <i32> [#uses=1] - %13 = icmp slt i32 %11, %12 ; <i1> [#uses=1] - br i1 %13, label %bb2, label %bb7 -; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb2] [3.000000e+00 -> bb7] - -bb7: ; preds = %bb6 -; PROF:bb7: -; PROF: ;;; Basic block executed 3 times. - br label %bb9 -; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb9] - -bb8: ; preds = %bb -; PROF:bb8: -; PROF: ;;; Basic block executed 3 times. - %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; <i32> [#uses=0] - br label %bb9 -; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb9] - -bb9: ; preds = %bb8, %bb7 -; PROF:bb9: -; PROF: ;;; Basic block executed 6 times. - %15 = load i32* %i, align 4 ; <i32> [#uses=1] - %16 = add nsw i32 %15, 1 ; <i32> [#uses=1] - store i32 %16, i32* %i, align 4 - br label %bb10 -; PROF: ;;; Out-edge counts: [6.000000e+00 -> bb10] - -bb10: ; preds = %bb9, %entry -; PROF:bb10: -; PROF: ;;; Basic block executed 8 times. - %17 = load i32* %i, align 4 ; <i32> [#uses=1] - %18 = icmp ne i32 %17, 3 ; <i1> [#uses=1] - br i1 %18, label %bb, label %bb11 -; INST:br -; INST:label %bb10.bb11_crit_edge -; PROF: ;;; Out-edge counts: [6.000000e+00 -> bb] [2.000000e+00 -> bb11] - -; INST:bb10.bb11_crit_edge: -; INST:br -; INST:label %bb11 - -bb11: ; preds = %bb10, %bb4 -; PROF:bb11: -; PROF: ;;; Basic block executed 2 times. - call void @oneblock() nounwind - store i32 0, i32* %0, align 4 - %19 = load i32* %0, align 4 ; <i32> [#uses=1] - store i32 %19, i32* %retval, align 4 - br label %return -; PROF: ;;; Out-edge counts: [2.000000e+00 -> return] - -return: ; preds = %bb11 -; PROF:return: -; PROF: ;;; Basic block executed 2 times. - %retval12 = load i32* %retval ; <i32> [#uses=1] - ret i32 %retval12 -} diff --git a/test/Analysis/RegionInfo/lit.local.cfg b/test/Analysis/RegionInfo/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/RegionInfo/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll b/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll index e0c5583cbb97d..b5eb9fc4878df 100644 --- a/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll +++ b/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll @@ -1,9 +1,10 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep "Loop %bb: backedge-taken count is 100" +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR1533 @array = weak global [101 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=1] +; CHECK: Loop %bb: backedge-taken count is 100 + define void @loop(i32 %x) { entry: br label %bb diff --git a/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll b/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll index e67e4d00d6258..fd09fd5f28c57 100644 --- a/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll +++ b/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll @@ -1,6 +1,8 @@ -; RUN: opt < %s -indvars -adce -simplifycfg -S | grep "icmp s" +; RUN: opt < %s -indvars -adce -simplifycfg -S | FileCheck %s ; PR1598 +; CHECK: icmp s + define i32 @f(i32 %a, i32 %b, i32 %x, i32 %y) { entry: %tmp3 = icmp eq i32 %a, %b ; <i1> [#uses=1] diff --git a/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll b/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll index 036abf5b7c166..9e19ccab6eb1c 100644 --- a/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll +++ b/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll @@ -1,6 +1,8 @@ -; RUN: opt < %s -scalar-evolution -analyze | grep "Loop %bb: backedge-taken count is (-1 + (-1 \* %x) + %y)" +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s ; PR1597 +; CHECK: Loop %bb: backedge-taken count is (-1 + (-1 * %x) + %y) + define i32 @f(i32 %x, i32 %y) { entry: %tmp63 = icmp ult i32 %x, %y ; <i1> [#uses=1] diff --git a/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll b/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll index a3192b9c01fde..b65a525024474 100644 --- a/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll +++ b/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll @@ -1,7 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep "backedge-taken count is 13" +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR1706 +; CHECK: backedge-taken count is 13 + define i32 @f() { entry: br label %bb5 diff --git a/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll b/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll index 514920f0f6fad..a2850d8c4b4f5 100644 --- a/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll +++ b/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll @@ -1,6 +1,8 @@ -; RUN: opt < %s -indvars -S | grep printd | grep 1206807378 +; RUN: opt < %s -indvars -S | FileCheck %s ; PR1798 +; CHECK: printd(i32 1206807378) + declare void @printd(i32) define i32 @test() { diff --git a/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll b/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll index d0644f7b3f9da..6ebfa61de41d1 100644 --- a/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll +++ b/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll @@ -1,4 +1,6 @@ -; RUN: opt < %s -scalar-evolution -analyze | grep "Loop %header: backedge-taken count is (0 smax %n)" +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s + +; CHECK: Loop %header: backedge-taken count is (0 smax %n) define void @foo(i32 %n) { entry: diff --git a/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll b/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll index 52c7985045d09..527fd273cd25b 100644 --- a/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll +++ b/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll @@ -1,6 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution | grep umax +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR2003 +; CHECK: umax + define i32 @foo(i32 %n) { entry: br label %header diff --git a/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll b/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll index 41734d70f0717..9a05d88c4ce7c 100644 --- a/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll +++ b/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll @@ -1,7 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep "backedge-taken count is 61" +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR2364 +; CHECK: backedge-taken count is 61 + define i32 @func_6() nounwind { entry: br label %bb5 diff --git a/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll index 5cf17a2101405..dcf8fc9dbdb0f 100644 --- a/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll +++ b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll @@ -1,6 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution 2>&1 | not grep smax +; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s ; PR2261 +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'foo' +; CHECK-NOT: smax + @lut = common global [256 x i8] zeroinitializer, align 32 ; <[256 x i8]*> [#uses=1] define void @foo(i32 %count, i32* %srcptr, i32* %dstptr) nounwind { diff --git a/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll index 195dfaaaee95a..c804bd905510c 100644 --- a/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll +++ b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll @@ -1,6 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution 2>&1 | not grep smax +; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s ; PR2070 +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'a' +; CHECK-NOT: smax + define i32 @a(i32 %x) nounwind { entry: icmp sgt i32 %x, 1 ; <i1>:0 [#uses=1] diff --git a/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll b/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll index 1865c059a9988..ad34f6cedf61d 100644 --- a/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll +++ b/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll @@ -1,7 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep Unpredictable +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR2088 +; CHECK: Unpredictable + define void @fun() { entry: br label %loop diff --git a/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll b/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll index cbf200e40f9bd..82b9d560425e0 100644 --- a/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll +++ b/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll @@ -1,7 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep "backedge-taken count is 113" +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR2088 +; CHECK: backedge-taken count is 113 + define void @fun() { entry: br label %loop diff --git a/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll b/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll index c25e4a3b2b23e..46c6c59e92c52 100644 --- a/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll +++ b/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll @@ -1,5 +1,6 @@ -; RUN: opt < %s -analyze -scalar-evolution 2>&1 | \ -; RUN: grep "Loop %bb: backedge-taken count is (7 + (-1 \* %argc))" +; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s + +; CHECK: Loop %bb: backedge-taken count is (7 + (-1 * %argc)) define i32 @main(i32 %argc, i8** %argv) nounwind { entry: diff --git a/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll b/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll index 56a83438830e7..7acf90c7330cb 100644 --- a/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll +++ b/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll @@ -1,5 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | grep "Loop %bb: Unpredictable backedge-taken count\." +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; CHECK: Loop %bb: backedge-taken count is ((-5 + %x) /u 3) +; CHECK: Loop %bb: max backedge-taken count is 1431655764 + ; ScalarEvolution can't compute a trip count because it doesn't know if ; dividing by the stride will have a remainder. This could theoretically diff --git a/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll b/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll index aaf6770676bd1..2b2296a3a24fa 100644 --- a/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll +++ b/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll @@ -1,5 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution 2>&1 | grep "/u 3" -; XFAIL: * +; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s + +; CHECK: Loop %bb: backedge-taken count is ((999 + (-1 * %x)) /u 3) +; CHECK: Loop %bb: max backedge-taken count is 334 + ; This is a tricky testcase for unsigned wrap detection which ScalarEvolution ; doesn't yet know how to do. diff --git a/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll b/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll index a1b3b7191658c..7a7a64001a697 100644 --- a/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll +++ b/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll @@ -1,4 +1,6 @@ -; RUN: opt < %s -analyze -scalar-evolution | grep "backedge-taken count is 255" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; CHECK: backedge-taken count is 255 define i32 @foo(i32 %x, i32 %y, i32* %lam, i32* %alp) nounwind { bb1.thread: diff --git a/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll b/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll index bb149193a0f4c..95aa1fc85e20c 100644 --- a/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll +++ b/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll @@ -1,7 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution 2>&1 | \ -; RUN: grep "(((-1 * %i0) + (100005 smax %i0)) /u 5)" +; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s ; XFAIL: * +; CHECK: (((-1 * %i0) + (100005 smax %i0)) /u 5) + define i32 @foo0(i32 %i0) nounwind { entry: br label %bb1 diff --git a/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll b/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll index 70006260cb9e9..70588bc0574e8 100644 --- a/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll +++ b/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll @@ -1,5 +1,6 @@ -; RUN: opt < %s -analyze -scalar-evolution 2>&1 | grep "/u 5" -; XFAIL: * +; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s + +; CHECK: /u 5 define i8 @foo0(i8 %i0) nounwind { entry: diff --git a/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll b/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll index 82f2608e57471..f19d18c72e69d 100644 --- a/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll +++ b/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll @@ -1,6 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution | not grep "/u -1" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR3275 +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'func_15' +; CHECK-NOT: /u -1 + @g_16 = external global i16 ; <i16*> [#uses=3] @.str = external constant [4 x i8] ; <[4 x i8]*> [#uses=0] diff --git a/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll b/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll index ebd9f7377d0c9..3dacfbb0a8d49 100644 --- a/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll +++ b/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll @@ -1,35 +1,53 @@ ; RUN: opt < %s -analyze -scalar-evolution | grep "(trunc i" | not grep ext +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'test1' +; CHECK-NOT: (trunc i{{.*}}ext + define i16 @test1(i8 %x) { %A = sext i8 %x to i32 %B = trunc i32 %A to i16 ret i16 %B } +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'test2' +; CHECK-NOT: (trunc i{{.*}}ext + define i8 @test2(i16 %x) { %A = sext i16 %x to i32 %B = trunc i32 %A to i8 ret i8 %B } +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'test3' +; CHECK-NOT: (trunc i{{.*}}ext + define i16 @test3(i16 %x) { %A = sext i16 %x to i32 %B = trunc i32 %A to i16 ret i16 %B } +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'test4' +; CHECK-NOT: (trunc i{{.*}}ext + define i16 @test4(i8 %x) { %A = zext i8 %x to i32 %B = trunc i32 %A to i16 ret i16 %B } +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'test5' +; CHECK-NOT: (trunc i{{.*}}ext + define i8 @test5(i16 %x) { %A = zext i16 %x to i32 %B = trunc i32 %A to i8 ret i8 %B } +; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'test6' +; CHECK-NOT: (trunc i{{.*}}ext + define i16 @test6(i16 %x) { %A = zext i16 %x to i32 %B = trunc i32 %A to i16 diff --git a/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll b/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll index 8a780431345e2..5d1502da179f8 100644 --- a/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll +++ b/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll @@ -1,5 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution | grep "count is 2" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR3171 + +; CHECK: count is 2 + target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.Foo = type { i32 } diff --git a/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll b/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll index 1600d5f05a188..973dd7d6dd0d2 100644 --- a/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll +++ b/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll @@ -30,4 +30,4 @@ for.inc9: if.then: ret i8 0 -}
\ No newline at end of file +} diff --git a/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll b/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll index e946d7a64bc97..2cb8c5bf46ffc 100644 --- a/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll +++ b/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll @@ -1,5 +1,4 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | FileCheck %s +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR1101 diff --git a/test/Analysis/ScalarEvolution/and-xor.ll b/test/Analysis/ScalarEvolution/and-xor.ll index 06f4a8582fa19..404ab91e269d2 100644 --- a/test/Analysis/ScalarEvolution/and-xor.ll +++ b/test/Analysis/ScalarEvolution/and-xor.ll @@ -1,5 +1,8 @@ -; RUN: opt < %s -scalar-evolution -analyze \ -; RUN: | grep "\--> (zext" | count 2 +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s + +; CHECK: --> (zext +; CHECK: --> (zext +; CHECK-NOT: --> (zext define i32 @foo(i32 %x) { %n = and i32 %x, 255 diff --git a/test/Analysis/ScalarEvolution/avoid-smax-0.ll b/test/Analysis/ScalarEvolution/avoid-smax-0.ll index 3d15c787fcfe7..8abb43074c5e4 100644 --- a/test/Analysis/ScalarEvolution/avoid-smax-0.ll +++ b/test/Analysis/ScalarEvolution/avoid-smax-0.ll @@ -1,4 +1,6 @@ -; RUN: opt < %s -scalar-evolution -analyze | grep "Loop %bb3: backedge-taken count is (-1 + %n)" +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s + +; CHECK: Loop %bb3: backedge-taken count is (-1 + %n) ; We don't want to use a max in the trip count expression in ; this testcase. diff --git a/test/Analysis/ScalarEvolution/div-overflow.ll b/test/Analysis/ScalarEvolution/div-overflow.ll index 28467975606f5..aca964ae62b6e 100644 --- a/test/Analysis/ScalarEvolution/div-overflow.ll +++ b/test/Analysis/ScalarEvolution/div-overflow.ll @@ -1,5 +1,6 @@ -; RUN: opt < %s -scalar-evolution -analyze \ -; RUN: | grep "\--> ((-128 \* %a) /u -128)" +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s + +; CHECK: --> ((-128 * %a) /u -128) ; Don't let ScalarEvolution fold this div away. diff --git a/test/Analysis/ScalarEvolution/do-loop.ll b/test/Analysis/ScalarEvolution/do-loop.ll index 6e3295a920b05..e35ea7d57e3a5 100644 --- a/test/Analysis/ScalarEvolution/do-loop.ll +++ b/test/Analysis/ScalarEvolution/do-loop.ll @@ -1,6 +1,8 @@ -; RUN: opt < %s -analyze -scalar-evolution | grep smax +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR1614 +; CHECK: smax + define i32 @f(i32 %x, i32 %y) { entry: br label %bb diff --git a/test/Analysis/ScalarEvolution/lit.local.cfg b/test/Analysis/ScalarEvolution/lit.local.cfg deleted file mode 100644 index c6106e4746f2d..0000000000000 --- a/test/Analysis/ScalarEvolution/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll'] diff --git a/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll b/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll new file mode 100644 index 0000000000000..aa5254c758bf8 --- /dev/null +++ b/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll @@ -0,0 +1,68 @@ +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; ScalarEvolution should be able to understand the loop and eliminate the casts. + +target datalayout = "e-p:32:32:32-p1:16:16:16-p2:8:8:8-p4:64:64:64-n16:32:64" + +; CHECK: {%d,+,4}<%bb> Exits: ((4 * (trunc i32 (-1 + %n) to i16)) + %d) + + +define void @foo(i32 addrspace(1)* nocapture %d, i32 %n) nounwind { +; CHECK: @foo +entry: + %0 = icmp sgt i32 %n, 0 ; <i1> [#uses=1] + br i1 %0, label %bb.nph, label %return + +bb.nph: ; preds = %entry + br label %bb + +bb: ; preds = %bb1, %bb.nph + %i.02 = phi i32 [ %5, %bb1 ], [ 0, %bb.nph ] ; <i32> [#uses=2] + %p.01 = phi i8 [ %4, %bb1 ], [ -1, %bb.nph ] ; <i8> [#uses=2] + %1 = sext i8 %p.01 to i32 ; <i32> [#uses=1] + %2 = sext i32 %i.02 to i64 ; <i64> [#uses=1] + %3 = getelementptr i32 addrspace(1)* %d, i64 %2 ; <i32*> [#uses=1] + store i32 %1, i32 addrspace(1)* %3, align 4 + %4 = add i8 %p.01, 1 ; <i8> [#uses=1] + %5 = add i32 %i.02, 1 ; <i32> [#uses=2] + br label %bb1 + +bb1: ; preds = %bb + %6 = icmp slt i32 %5, %n ; <i1> [#uses=1] + br i1 %6, label %bb, label %bb1.return_crit_edge + +bb1.return_crit_edge: ; preds = %bb1 + br label %return + +return: ; preds = %bb1.return_crit_edge, %entry + ret void +} + +define void @test(i8 addrspace(1)* %a, i32 %n) nounwind { +; CHECK: @test +entry: + %cmp1 = icmp sgt i32 %n, 0 + br i1 %cmp1, label %for.body.lr.ph, label %for.end + +for.body.lr.ph: ; preds = %entry + %tmp = zext i32 %n to i64 + br label %for.body + +for.body: ; preds = %for.body, %for.body.lr.ph + %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.lr.ph ] + %arrayidx = getelementptr i8 addrspace(1)* %a, i64 %indvar + store i8 0, i8 addrspace(1)* %arrayidx, align 1 + %indvar.next = add i64 %indvar, 1 + %exitcond = icmp ne i64 %indvar.next, %tmp + br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge + +for.cond.for.end_crit_edge: ; preds = %for.body + br label %for.end + +for.end: ; preds = %for.cond.for.end_crit_edge, %entry + ret void +} + +; CHECK: Determining loop execution counts for: @test +; CHECK-NEXT: backedge-taken count is +; CHECK-NEXT: max backedge-taken count is -1 diff --git a/test/Analysis/ScalarEvolution/nsw.ll b/test/Analysis/ScalarEvolution/nsw.ll index 659cf4f8da972..05992eadbac03 100644 --- a/test/Analysis/ScalarEvolution/nsw.ll +++ b/test/Analysis/ScalarEvolution/nsw.ll @@ -62,11 +62,11 @@ for.body.lr.ph.i.i: ; preds = %entry for.body.i.i: ; preds = %for.body.i.i, %for.body.lr.ph.i.i %__first.addr.02.i.i = phi i32* [ %begin, %for.body.lr.ph.i.i ], [ %ptrincdec.i.i, %for.body.i.i ] ; CHECK: %__first.addr.02.i.i -; CHECK-NEXT: --> {%begin,+,4}<nw><%for.body.i.i> +; CHECK-NEXT: --> {%begin,+,4}<nuw><%for.body.i.i> store i32 0, i32* %__first.addr.02.i.i, align 4 %ptrincdec.i.i = getelementptr inbounds i32* %__first.addr.02.i.i, i64 1 ; CHECK: %ptrincdec.i.i -; CHECK-NEXT: --> {(4 + %begin),+,4}<nw><%for.body.i.i> +; CHECK-NEXT: --> {(4 + %begin),+,4}<nuw><%for.body.i.i> %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end br i1 %cmp.i.i, label %for.cond.for.end_crit_edge.i.i, label %for.body.i.i @@ -122,3 +122,39 @@ exit: %result = phi i32 [ %a, %entry ], [ %tmp2, %greater ] ret i32 %result } + +; TODO: This could fold down to '1' +; CHECK-LABEL: PR12375 +; CHECK: --> {(4 + %arg),+,4}<nuw><%bb1> Exits: (4 + (4 * ((-1 + (-1 * %arg) + ((4 + %arg) umax (8 + %arg)<nsw>)) /u 4)) + %arg) +define i32 @PR12375(i32* readnone %arg) { +bb: + %tmp = getelementptr inbounds i32* %arg, i64 2 + br label %bb1 + +bb1: ; preds = %bb1, %bb + %tmp2 = phi i32* [ %arg, %bb ], [ %tmp5, %bb1 ] + %tmp3 = phi i32 [ 0, %bb ], [ %tmp4, %bb1 ] + %tmp4 = add nsw i32 %tmp3, 1 + %tmp5 = getelementptr inbounds i32* %tmp2, i64 1 + %tmp6 = icmp ult i32* %tmp5, %tmp + br i1 %tmp6, label %bb1, label %bb7 + +bb7: ; preds = %bb1 + ret i32 %tmp4 +} + +; CHECK-LABEL: PR12376 +; CHECK: --> {(4 + %arg),+,4}<nuw><%bb2> Exits: (4 + (4 * ((3 + (-1 * %arg) + (%arg umax %arg1)) /u 4)) + %arg) +define void @PR12376(i32* nocapture %arg, i32* nocapture %arg1) { +bb: + br label %bb2 + +bb2: ; preds = %bb2, %bb + %tmp = phi i32* [ %arg, %bb ], [ %tmp4, %bb2 ] + %tmp3 = icmp ult i32* %tmp, %arg1 + %tmp4 = getelementptr inbounds i32* %tmp, i64 1 + br i1 %tmp3, label %bb2, label %bb5 + +bb5: ; preds = %bb2 + ret void +} diff --git a/test/Analysis/ScalarEvolution/smax.ll b/test/Analysis/ScalarEvolution/smax.ll index eceb4298fd50c..122e9e47e56f4 100644 --- a/test/Analysis/ScalarEvolution/smax.ll +++ b/test/Analysis/ScalarEvolution/smax.ll @@ -1,8 +1,10 @@ -; RUN: opt < %s -analyze -scalar-evolution | grep smax | count 2 -; RUN: opt < %s -analyze -scalar-evolution | grep \ -; RUN: "%. smax %. smax %." +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR1614 +; CHECK: --> (%a smax %b) +; CHECK: --> (%a smax %b smax %c) +; CHECK-NOT: smax + define i32 @x(i32 %a, i32 %b, i32 %c) { %A = icmp sgt i32 %a, %b %B = select i1 %A, i32 %a, i32 %b diff --git a/test/Analysis/ScalarEvolution/trip-count.ll b/test/Analysis/ScalarEvolution/trip-count.ll index 94f6882c0c914..f89125aeb29b6 100644 --- a/test/Analysis/ScalarEvolution/trip-count.ll +++ b/test/Analysis/ScalarEvolution/trip-count.ll @@ -1,9 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep "backedge-taken count is 10000" +; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s ; PR1101 @A = weak global [1000 x i32] zeroinitializer, align 32 +; CHECK: backedge-taken count is 10000 define void @test(i32 %N) { entry: diff --git a/test/Analysis/ScalarEvolution/trip-count10.ll b/test/Analysis/ScalarEvolution/trip-count10.ll index 546e1dc7d8f7c..ead80b950409d 100644 --- a/test/Analysis/ScalarEvolution/trip-count10.ll +++ b/test/Analysis/ScalarEvolution/trip-count10.ll @@ -3,7 +3,7 @@ ; Trip counts with trivial exit conditions. ; CHECK: Determining loop execution counts for: @a -; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable backedge-taken count. ; CHECK: Loop %loop: Unpredictable max backedge-taken count. ; CHECK: Determining loop execution counts for: @b @@ -15,8 +15,8 @@ ; CHECK: Loop %loop: max backedge-taken count is false ; CHECK: Determining loop execution counts for: @d -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable max backedge-taken count. define void @a(i64 %n) nounwind { entry: @@ -124,3 +124,28 @@ loop: return: ret void } + +; PR16130: Loop exit depends on an 'or' expression. +; One side of the expression test against a value that will be skipped. +; We can't assume undefined behavior just because we have an NSW flag. +; +; CHECK: Determining loop execution counts for: @exit_orcond_nsw +; CHECK: Loop %for.body.i: Unpredictable backedge-taken count. +; CHECK: Loop %for.body.i: max backedge-taken count is 1 +define void @exit_orcond_nsw(i32 *%a) nounwind { +entry: + br label %for.body.i + +for.body.i: ; preds = %for.body.i, %entry + %b.01.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ] + %tobool.i = icmp ne i32 %b.01.i, 0 + %add.i = add nsw i32 %b.01.i, 8 + %cmp.i = icmp eq i32 %add.i, 13 + %or.cond = or i1 %tobool.i, %cmp.i + br i1 %or.cond, label %exit, label %for.body.i + +exit: ; preds = %for.body.i + %b.01.i.lcssa = phi i32 [ %b.01.i, %for.body.i ] + store i32 %b.01.i.lcssa, i32* %a, align 4 + ret void +} diff --git a/test/Analysis/ScalarEvolution/trip-count11.ll b/test/Analysis/ScalarEvolution/trip-count11.ll index 71915037ec8ba..e14af08e33f8a 100644 --- a/test/Analysis/ScalarEvolution/trip-count11.ll +++ b/test/Analysis/ScalarEvolution/trip-count11.ll @@ -1,9 +1,11 @@ ; RUN: opt < %s -analyze -scalar-evolution | 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-S128" +target datalayout = "e-p:64:64:64-p1:16:16:16-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-S128" target triple = "x86_64-unknown-linux-gnu" @foo.a = internal constant [8 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7], align 16 +@foo.a_as1 = internal addrspace(1) constant [8 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7], align 16 + define i32 @foo() nounwind uwtable noinline { entry: @@ -27,3 +29,27 @@ for.inc: ; preds = %for.cond for.end: ; preds = %for.cond ret i32 %sum.0 } + +define i32 @foo_as1() nounwind uwtable noinline { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ] +; CHECK: --> %sum.0 Exits: 28 + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %cmp = icmp ult i32 %i.0, 8 + br i1 %cmp, label %for.inc, label %for.end + +for.inc: ; preds = %for.cond + %idxprom = sext i32 %i.0 to i64 + %arrayidx = getelementptr inbounds [8 x i32] addrspace(1)* @foo.a_as1, i64 0, i64 %idxprom + %0 = load i32 addrspace(1)* %arrayidx, align 4 + %add = add nsw i32 %sum.0, %0 + %inc = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret i32 %sum.0 +} + diff --git a/test/Analysis/ScalarEvolution/trip-count2.ll b/test/Analysis/ScalarEvolution/trip-count2.ll index d84e99f6e7ca9..e76488abfca51 100644 --- a/test/Analysis/ScalarEvolution/trip-count2.ll +++ b/test/Analysis/ScalarEvolution/trip-count2.ll @@ -1,9 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution | \ -; RUN: grep "backedge-taken count is 4" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR1101 @A = weak global [1000 x i32] zeroinitializer, align 32 +; CHECK: backedge-taken count is 4 define void @test(i32 %N) { entry: diff --git a/test/Analysis/ScalarEvolution/trip-count3.ll b/test/Analysis/ScalarEvolution/trip-count3.ll index 0cb6c952b8939..850e035e7c6b8 100644 --- a/test/Analysis/ScalarEvolution/trip-count3.ll +++ b/test/Analysis/ScalarEvolution/trip-count3.ll @@ -1,10 +1,12 @@ -; RUN: opt < %s -scalar-evolution -analyze \ -; RUN: | grep "Loop %bb3\.i: Unpredictable backedge-taken count\." +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s ; ScalarEvolution can't compute a trip count because it doesn't know if ; dividing by the stride will have a remainder. This could theoretically ; be teaching it how to use a more elaborate trip count computation. +; CHECK: Loop %bb3.i: backedge-taken count is ((64 + (-64 smax (-1 + (-1 * %0))) + %0) /u 64) +; CHECK: Loop %bb3.i: max backedge-taken count is 33554431 + %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] } %struct.SHA_INFO = type { [5 x i32], i32, i32, [16 x i32] } %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 } diff --git a/test/Analysis/ScalarEvolution/trip-count4.ll b/test/Analysis/ScalarEvolution/trip-count4.ll index c02ae145268f5..b7184a48fe854 100644 --- a/test/Analysis/ScalarEvolution/trip-count4.ll +++ b/test/Analysis/ScalarEvolution/trip-count4.ll @@ -1,8 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | grep "sext.*trunc.*Exits: 11" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; ScalarEvolution should be able to compute a loop exit value for %indvar.i8. +; CHECK: sext{{.*}}trunc{{.*}}Exits: 11 + define void @another_count_down_signed(double* %d, i64 %n) nounwind { entry: br label %loop diff --git a/test/Analysis/ScalarEvolution/trip-count6.ll b/test/Analysis/ScalarEvolution/trip-count6.ll index 882f5526da4c0..0f394a09d156e 100644 --- a/test/Analysis/ScalarEvolution/trip-count6.ll +++ b/test/Analysis/ScalarEvolution/trip-count6.ll @@ -1,8 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | grep "max backedge-taken count is 1$" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s @mode_table = global [4 x i32] zeroinitializer ; <[4 x i32]*> [#uses=1] +; CHECK: max backedge-taken count is 1{{$}} + define i8 @f() { entry: tail call i32 @fegetround( ) ; <i32>:0 [#uses=1] diff --git a/test/Analysis/ScalarEvolution/trip-count7.ll b/test/Analysis/ScalarEvolution/trip-count7.ll index 2bcb9e92abcce..d01a18a468f0f 100644 --- a/test/Analysis/ScalarEvolution/trip-count7.ll +++ b/test/Analysis/ScalarEvolution/trip-count7.ll @@ -1,8 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | grep "Loop %bb7.i: Unpredictable backedge-taken count\." +; RUN: opt < %s -analyze -scalar-evolution | 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" +; CHECK: Loop %bb7.i: Unpredictable backedge-taken count. + %struct.complex = type { float, float } %struct.element = type { i32, i32 } %struct.node = type { %struct.node*, %struct.node*, i32 } diff --git a/test/Analysis/ScalarEvolution/trip-count8.ll b/test/Analysis/ScalarEvolution/trip-count8.ll index 005162b792127..a1777bc969c9d 100644 --- a/test/Analysis/ScalarEvolution/trip-count8.ll +++ b/test/Analysis/ScalarEvolution/trip-count8.ll @@ -1,9 +1,10 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | grep "Loop %for\.body: backedge-taken count is (-1 + [%]ecx)" +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR4599 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" +; CHECK: Loop %for.body: backedge-taken count is (-1 + {{%?}}ecx) + define i32 @foo(i32 %ecx) nounwind { entry: %cmp2 = icmp eq i32 %ecx, 0 ; <i1> [#uses=1] diff --git a/test/Analysis/ScalarEvolution/trip-count9.ll b/test/Analysis/ScalarEvolution/trip-count9.ll index 9180f2b8dd7f7..9a080b34743f9 100644 --- a/test/Analysis/ScalarEvolution/trip-count9.ll +++ b/test/Analysis/ScalarEvolution/trip-count9.ll @@ -25,8 +25,8 @@ exit: } ; CHECK: Determining loop execution counts for: @step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable max backedge-taken count. define void @step2(i4 %n) { entry: %s = icmp sgt i4 %n, 0 @@ -57,8 +57,8 @@ exit: } ; CHECK: Determining loop execution counts for: @start1_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable max backedge-taken count. define void @start1_step2(i4 %n) { entry: %s = icmp sgt i4 %n, 0 @@ -89,8 +89,8 @@ exit: } ; CHECK: Determining loop execution counts for: @startx_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable max backedge-taken count. define void @startx_step2(i4 %n, i4 %x) { entry: %s = icmp sgt i4 %n, 0 @@ -120,12 +120,18 @@ exit: ret void } -; Be careful with this one. If %n is INT4_MAX, %i.next will wrap. The nsw bit -; says that the result is undefined, but ScalarEvolution must respect that -; subsequent passes may result the undefined behavior in predictable ways. +; If %n is INT4_MAX, %i.next will wrap. The nsw bit says that the +; result is undefined. Therefore, after the loop's second iteration, +; we are free to assume that the loop exits. This is valid because: +; (a) %i.next is a poison value after the second iteration, which can +; also be considered an undef value. +; (b) the return instruction enacts a side effect that is control +; dependent on the poison value. +; +; CHECK-LABEL: nsw_step2 ; CHECK: Determining loop execution counts for: @nsw_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: backedge-taken count is ((-1 + %n) /u 2) +; CHECK: Loop %loop: max backedge-taken count is 2 define void @nsw_step2(i4 %n) { entry: %s = icmp sgt i4 %n, 0 @@ -139,6 +145,7 @@ exit: ret void } +; CHECK-LABEL: nsw_start1 ; CHECK: Determining loop execution counts for: @nsw_start1 ; CHECK: Loop %loop: backedge-taken count is (-2 + (2 smax %n)) ; CHECK: Loop %loop: max backedge-taken count is 5 @@ -156,8 +163,8 @@ exit: } ; CHECK: Determining loop execution counts for: @nsw_start1_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: backedge-taken count is ((-2 + (3 smax %n)) /u 2) +; CHECK: Loop %loop: max backedge-taken count is 2 define void @nsw_start1_step2(i4 %n) { entry: %s = icmp sgt i4 %n, 0 @@ -188,8 +195,8 @@ exit: } ; CHECK: Determining loop execution counts for: @nsw_startx_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. -; CHECK: Loop %loop: Unpredictable max backedge-taken count. +; CHECK: Loop %loop: backedge-taken count is ((-1 + (-1 * %x) + ((2 + %x) smax %n)) /u 2) +; CHECK: Loop %loop: max backedge-taken count is 7 define void @nsw_startx_step2(i4 %n, i4 %x) { entry: %s = icmp sgt i4 %n, 0 @@ -221,7 +228,7 @@ exit: } ; CHECK: Determining loop execution counts for: @even_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: backedge-taken count is ((-1 + (2 * %n)) /u 2) ; CHECK: Loop %loop: max backedge-taken count is 2 define void @even_step2(i4 %n) { entry: @@ -255,7 +262,7 @@ exit: } ; CHECK: Determining loop execution counts for: @even_start1_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: backedge-taken count is ((-2 + (3 smax (2 * %n))) /u 2) ; CHECK: Loop %loop: max backedge-taken count is 2 define void @even_start1_step2(i4 %n) { entry: @@ -273,7 +280,7 @@ exit: ; CHECK: Determining loop execution counts for: @even_startx ; CHECK: Loop %loop: backedge-taken count is (-1 + (-1 * %x) + ((1 + %x) smax (2 * %n))) -; CHECK: Loop %loop: max backedge-taken count is -1 +; CHECK: Loop %loop: max backedge-taken count is -2 define void @even_startx(i4 %n, i4 %x) { entry: %m = shl i4 %n, 1 @@ -289,7 +296,7 @@ exit: } ; CHECK: Determining loop execution counts for: @even_startx_step2 -; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: backedge-taken count is ((-1 + (-1 * %x) + ((2 + %x) smax (2 * %n))) /u 2) ; CHECK: Loop %loop: max backedge-taken count is 7 define void @even_startx_step2(i4 %n, i4 %x) { entry: @@ -375,7 +382,7 @@ exit: ; CHECK: Determining loop execution counts for: @even_nsw_startx ; CHECK: Loop %loop: backedge-taken count is (-1 + (-1 * %x) + ((1 + %x) smax (2 * %n))) -; CHECK: Loop %loop: max backedge-taken count is -1 +; CHECK: Loop %loop: max backedge-taken count is -2 define void @even_nsw_startx(i4 %n, i4 %x) { entry: %m = shl i4 %n, 1 diff --git a/test/Analysis/ScalarEvolution/xor-and.ll b/test/Analysis/ScalarEvolution/xor-and.ll index 4ab2f39a2810a..2616ea928a494 100644 --- a/test/Analysis/ScalarEvolution/xor-and.ll +++ b/test/Analysis/ScalarEvolution/xor-and.ll @@ -1,9 +1,10 @@ -; RUN: opt < %s -scalar-evolution -analyze \ -; RUN: | grep "\--> (zext i4 (-8 + (trunc i64 (8 \* %x) to i4)) to i64)" +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s ; ScalarEvolution shouldn't try to analyze %z into something like ; --> (zext i4 (-1 + (-1 * (trunc i64 (8 * %x) to i4))) to i64) +; CHECK: --> (zext i4 (-8 + (trunc i64 (8 * %x) to i4)) to i64) + define i64 @foo(i64 %x) { %a = shl i64 %x, 3 %t = and i64 %a, 8 diff --git a/test/Analysis/ScalarEvolution/zext-wrap.ll b/test/Analysis/ScalarEvolution/zext-wrap.ll index 38d15ffbd880e..104ed41010af0 100644 --- a/test/Analysis/ScalarEvolution/zext-wrap.ll +++ b/test/Analysis/ScalarEvolution/zext-wrap.ll @@ -1,5 +1,4 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | FileCheck %s +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; PR4569 define i16 @main() nounwind { diff --git a/test/Analysis/TypeBasedAliasAnalysis/PR17620.ll b/test/Analysis/TypeBasedAliasAnalysis/PR17620.ll new file mode 100644 index 0000000000000..905113995c30d --- /dev/null +++ b/test/Analysis/TypeBasedAliasAnalysis/PR17620.ll @@ -0,0 +1,45 @@ +; RUN: opt < %s -tbaa -gvn -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-S128" + +%structA = type { %structB } +%structB = type { i32*, %classT } +%classT = type { %classO, %classJ*, i8 } +%classO = type { i32 } +%classJ = type { i8 } +%classA = type { %classB } +%classB = type { i8 } +%classC = type { %classD, %structA } +%classD = type { %structA* } + +; Function Attrs: ssp uwtable +define %structA** @test(%classA* %this, i32** %p1) #0 align 2 { +entry: +; CHECK-LABEL: @test +; CHECK: load i32** %p1, align 8, !tbaa +; CHECK: load i32** getelementptr (%classC* null, i32 0, i32 1, i32 0, i32 0), align 8, !tbaa +; CHECK: call void @callee + %0 = load i32** %p1, align 8, !tbaa !1 + %1 = load i32** getelementptr (%classC* null, i32 0, i32 1, i32 0, i32 0), align 8, !tbaa !5 + call void @callee(i32* %0, i32* %1) + unreachable +} + +declare void @callee(i32*, i32*) #1 + +attributes #0 = { ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.ident = !{!0} + +!0 = metadata !{metadata !"clang version 3.4"} +!1 = metadata !{metadata !2, metadata !2, i64 0} +!2 = metadata !{metadata !"any pointer", metadata !3, i64 0} +!3 = metadata !{metadata !"omnipotent char", metadata !4, i64 0} +!4 = metadata !{metadata !"Simple C/C++ TBAA"} +!5 = metadata !{metadata !6, metadata !2, i64 8} +!6 = metadata !{metadata !"_ZTSN12_GLOBAL__N_11RINS_1FIPi8TreeIterN1I1S1LENS_1KINS_1DIKS2_S3_EEEEE1GEPSD_EE", metadata !7, i64 8} +!7 = metadata !{metadata !"_ZTSN12_GLOBAL__N_11FIPi8TreeIterN1I1S1LENS_1KINS_1DIKS1_S2_EEEEE1GE", metadata !8, i64 0} +!8 = metadata !{metadata !"_ZTSN12_GLOBAL__N_11DIKPi8TreeIterEE", metadata !2, i64 0, metadata !9, i64 8} +!9 = metadata !{metadata !"_ZTS8TreeIter", metadata !2, i64 8, metadata !10, i64 16} +!10 = metadata !{metadata !"bool", metadata !3, i64 0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll b/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll index d59e3924acd30..76a88c859a6bf 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll @@ -47,16 +47,21 @@ define i8 @test1_no(i8* %a, i8* %b) nounwind { ; Root note. !0 = metadata !{ } ; Some type. -!1 = metadata !{ metadata !"foo", metadata !0 } +!1 = metadata !{metadata !7, metadata !7, i64 0} ; Some other non-aliasing type. -!2 = metadata !{ metadata !"bar", metadata !0 } +!2 = metadata !{metadata !8, metadata !8, i64 0} ; Some type. -!3 = metadata !{ metadata !"foo", metadata !0 } +!3 = metadata !{metadata !9, metadata !9, i64 0} ; Some type in a different type system. -!4 = metadata !{ metadata !"bar", metadata !"different" } +!4 = metadata !{metadata !10, metadata !10, i64 0} ; Invariant memory. -!5 = metadata !{ metadata !"qux", metadata !0, i1 1 } +!5 = metadata !{metadata !11, metadata !11, i64 0, i1 1} ; Not invariant memory. -!6 = metadata !{ metadata !"qux", metadata !0, i1 0 } +!6 = metadata !{metadata !11, metadata !11, i64 0, i1 0} +!7 = metadata !{ metadata !"foo", metadata !0 } +!8 = metadata !{ metadata !"bar", metadata !0 } +!9 = metadata !{ metadata !"foo", metadata !0 } +!10 = metadata !{ metadata !"bar", metadata !"different" } +!11 = metadata !{ metadata !"qux", metadata !0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/argument-promotion.ll b/test/Analysis/TypeBasedAliasAnalysis/argument-promotion.ll index 3b5211e5999d1..14bbeac14d692 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/argument-promotion.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/argument-promotion.ll @@ -1,7 +1,9 @@ -; RUN: opt < %s -tbaa -basicaa -argpromotion -mem2reg -S | not grep alloca +; RUN: opt < %s -tbaa -basicaa -argpromotion -mem2reg -S | FileCheck %s target datalayout = "E-p:64:64:64" +; CHECK: test +; CHECK-NOT: alloca define internal i32 @test(i32* %X, i32* %Y, i32* %Q) { store i32 77, i32* %Q, !tbaa !2 %A = load i32* %X, !tbaa !1 @@ -10,6 +12,8 @@ define internal i32 @test(i32* %X, i32* %Y, i32* %Q) { ret i32 %C } +; CHECK: caller +; CHECK-NOT: alloca define internal i32 @caller(i32* %B, i32* %Q) { %A = alloca i32 store i32 78, i32* %Q, !tbaa !2 @@ -18,6 +22,8 @@ define internal i32 @caller(i32* %B, i32* %Q) { ret i32 %C } +; CHECK: callercaller +; CHECK-NOT: alloca define i32 @callercaller(i32* %Q) { %B = alloca i32 store i32 2, i32* %B, !tbaa !1 @@ -27,5 +33,7 @@ define i32 @callercaller(i32* %Q) { } !0 = metadata !{metadata !"test"} -!1 = metadata !{metadata !"green", metadata !0} -!2 = metadata !{metadata !"blue", metadata !0} +!1 = metadata !{metadata !3, metadata !3, i64 0} +!2 = metadata !{metadata !4, metadata !4, i64 0} +!3 = metadata !{metadata !"green", metadata !0} +!4 = metadata !{metadata !"blue", metadata !0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/dse.ll b/test/Analysis/TypeBasedAliasAnalysis/dse.ll index 6b44eb6384234..bcf1f2c5275df 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/dse.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/dse.ll @@ -51,16 +51,21 @@ define i8 @test1_no(i8* %a, i8* %b) nounwind { ; Root note. !0 = metadata !{ } ; Some type. -!1 = metadata !{ metadata !"foo", metadata !0 } +!1 = metadata !{metadata !7, metadata !7, i64 0} ; Some other non-aliasing type. -!2 = metadata !{ metadata !"bar", metadata !0 } +!2 = metadata !{metadata !8, metadata !8, i64 0} ; Some type. -!3 = metadata !{ metadata !"foo", metadata !0 } +!3 = metadata !{metadata !9, metadata !9, i64 0} ; Some type in a different type system. -!4 = metadata !{ metadata !"bar", metadata !"different" } +!4 = metadata !{metadata !10, metadata !10, i64 0} ; Invariant memory. -!5 = metadata !{ metadata !"qux", metadata !0, i1 1 } +!5 = metadata !{metadata !11, metadata !11, i64 0, i1 1} ; Not invariant memory. -!6 = metadata !{ metadata !"qux", metadata !0, i1 0 } +!6 = metadata !{metadata !11, metadata !11, i64 0, i1 0} +!7 = metadata !{ metadata !"foo", metadata !0 } +!8 = metadata !{ metadata !"bar", metadata !0 } +!9 = metadata !{ metadata !"foo", metadata !0 } +!10 = metadata !{ metadata !"bar", metadata !"different" } +!11 = metadata !{ metadata !"qux", metadata !0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/dynamic-indices.ll b/test/Analysis/TypeBasedAliasAnalysis/dynamic-indices.ll index 52e394b2d09ce..4dc40739edfb1 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/dynamic-indices.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/dynamic-indices.ll @@ -13,7 +13,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 ; CHECK: for.end: ; CHECK: %arrayidx31 = getelementptr inbounds %union.vector_t* %t, i64 0, i32 0, i64 1 -; CHECK: %tmp32 = load i64* %arrayidx31, align 8, !tbaa !3 +; CHECK: %tmp32 = load i64* %arrayidx31, align 8, !tbaa [[TAG:!.*]] define void @vrlh(%union.vector_t* %va, %union.vector_t* %vb, %union.vector_t* %vd) nounwind { entry: @@ -123,9 +123,15 @@ for.end: ; preds = %for.body ret float %tmp10 } -!0 = metadata !{metadata !"short", metadata !1} +; CHECK: [[TAG]] = metadata !{metadata [[TYPE_LL:!.*]], metadata [[TYPE_LL]], i64 0} +; CHECK: [[TYPE_LL]] = metadata !{metadata !"long long", metadata {{!.*}}} +!0 = metadata !{metadata !6, metadata !6, i64 0} !1 = metadata !{metadata !"omnipotent char", metadata !2} !2 = metadata !{metadata !"Simple C/C++ TBAA", null} -!3 = metadata !{metadata !"long long", metadata !1} -!4 = metadata !{metadata !"int", metadata !1} -!5 = metadata !{metadata !"float", metadata !1} +!3 = metadata !{metadata !7, metadata !7, i64 0} +!4 = metadata !{metadata !8, metadata !8, i64 0} +!5 = metadata !{metadata !9, metadata !9, i64 0} +!6 = metadata !{metadata !"short", metadata !1} +!7 = metadata !{metadata !"long long", metadata !1} +!8 = metadata !{metadata !"int", metadata !1} +!9 = metadata !{metadata !"float", metadata !1} diff --git a/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll b/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll index c6cc26a24106b..e9fb9418e7043 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll @@ -49,7 +49,7 @@ define void @test2_yes(i8* %p, i8* %q, i64 %n) nounwind { ret void } -; CHECK: define void @test2_no(i8* nocapture %p, i8* nocapture %q, i64 %n) #1 { +; CHECK: define void @test2_no(i8* nocapture %p, i8* nocapture readonly %q, i64 %n) #1 { define void @test2_no(i8* %p, i8* %q, i64 %n) nounwind { call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 %n, i32 1, i1 false), !tbaa !2 ret void @@ -80,6 +80,7 @@ declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1) nounwind !0 = metadata !{ } ; Invariant memory. -!1 = metadata !{ metadata !"foo", metadata !0, i1 1 } +!1 = metadata !{metadata !3, metadata !3, i64 0, i1 1 } ; Not invariant memory. -!2 = metadata !{ metadata !"foo", metadata !0, i1 0 } +!2 = metadata !{metadata !3, metadata !3, i64 0, i1 0 } +!3 = metadata !{ metadata !"foo", metadata !0 } diff --git a/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll b/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll index eceaa2cf02d34..90e1abbb673a5 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll @@ -85,7 +85,11 @@ if.else: } !0 = metadata !{} -!1 = metadata !{metadata !"red", metadata !0} -!2 = metadata !{metadata !"blu", metadata !0} -!3 = metadata !{metadata !"outer space"} -!4 = metadata !{metadata !"brick red", metadata !1} +!1 = metadata !{metadata !5, metadata !5, i64 0} +!2 = metadata !{metadata !6, metadata !6, i64 0} +!3 = metadata !{metadata !7, metadata !7, i64 0} +!4 = metadata !{metadata !8, metadata !8, i64 0} +!5 = metadata !{metadata !"red", metadata !0} +!6 = metadata !{metadata !"blu", metadata !0} +!7 = metadata !{metadata !"outer space"} +!8 = metadata !{metadata !"brick red", metadata !5} diff --git a/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll b/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll index 6f1c22da3ac5e..93b8e503b8558 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll @@ -26,5 +26,7 @@ declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind ; CHECK: attributes [[NUW]] = { nounwind } !0 = metadata !{metadata !"tbaa root", null} -!1 = metadata !{metadata !"A", metadata !0} -!2 = metadata !{metadata !"B", metadata !0} +!1 = metadata !{metadata !3, metadata !3, i64 0} +!2 = metadata !{metadata !4, metadata !4, i64 0} +!3 = metadata !{metadata !"A", metadata !0} +!4 = metadata !{metadata !"B", metadata !0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/licm.ll b/test/Analysis/TypeBasedAliasAnalysis/licm.ll index 12a9c1dc56497..e45fc85478d3e 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/licm.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/licm.ll @@ -30,8 +30,8 @@ for.end: ; preds = %for.body, %entry } !0 = metadata !{metadata !"root", null} -!1 = metadata !{metadata !"pointer", metadata !0} -!2 = metadata !{metadata !"double", metadata !0} +!1 = metadata !{metadata !6, metadata !6, i64 0} +!2 = metadata !{metadata !7, metadata !7, i64 0} ; LICM shouldn't hoist anything here. @@ -56,6 +56,10 @@ loop: br label %loop } -!3 = metadata !{metadata !"pointer", metadata !4} -!4 = metadata !{metadata !"char", metadata !5} -!5 = metadata !{metadata !"root", null} +!3 = metadata !{metadata !"pointer", metadata !8} +!4 = metadata !{metadata !8, metadata !8, i64 0} +!5 = metadata !{metadata !9, metadata !9, i64 0} +!6 = metadata !{metadata !"pointer", metadata !0} +!7 = metadata !{metadata !"double", metadata !0} +!8 = metadata !{metadata !"char", metadata !9} +!9 = metadata !{metadata !"root", null} diff --git a/test/Analysis/TypeBasedAliasAnalysis/lit.local.cfg b/test/Analysis/TypeBasedAliasAnalysis/lit.local.cfg deleted file mode 100644 index 19eebc0ac7ac3..0000000000000 --- a/test/Analysis/TypeBasedAliasAnalysis/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll b/test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll index c2407dfd4c89c..6fd6eaca012e9 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll @@ -7,7 +7,7 @@ target datalayout = "e-p:64:64:64" ; CHECK: @foo ; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 16, i32 1, i1 false), !tbaa !0 -; CHECK-NEXT: store i8 2, i8* %s, align 1, !tbaa !2 +; CHECK-NEXT: store i8 2, i8* %s, align 1, !tbaa [[TAGA:!.*]] ; CHECK-NEXT: ret void define void @foo(i8* nocapture %p, i8* nocapture %q, i8* nocapture %s) nounwind { tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 16, i32 1, i1 false), !tbaa !2 @@ -18,6 +18,10 @@ define void @foo(i8* nocapture %p, i8* nocapture %q, i8* nocapture %s) nounwind declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind +; CHECK [[TAGA]] = metadata !{metadata [[TYPEA:!.*]], metadata [[TYPEA]], i64 0} +; CHECK [[TYPEA]] = metadata !{metadata !"A", metadata !{{.*}}} !0 = metadata !{metadata !"tbaa root", null} -!1 = metadata !{metadata !"A", metadata !0} -!2 = metadata !{metadata !"B", metadata !0} +!1 = metadata !{metadata !3, metadata !3, i64 0} +!2 = metadata !{metadata !4, metadata !4, i64 0} +!3 = metadata !{metadata !"A", metadata !0} +!4 = metadata !{metadata !"B", metadata !0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/placement-tbaa.ll b/test/Analysis/TypeBasedAliasAnalysis/placement-tbaa.ll index f1edb4482cf1f..609e87c2313f1 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/placement-tbaa.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/placement-tbaa.ll @@ -18,7 +18,7 @@ ; Basic AA says MayAlias, TBAA says NoAlias ; CHECK: MayAlias: i64* %i5, i8** %p -; CHECK: NoAlias: store i64 %conv, i64* %i5, align 8, !tbaa !4 <-> store i8* null, i8** %p, align 8, !tbaa !3 +; CHECK: NoAlias: store i64 %conv, i64* %i5, align 8, !tbaa !6 <-> store i8* null, i8** %p, align 8, !tbaa !9 %struct.Foo = type { i64 } %struct.Bar = type { i8* } @@ -32,10 +32,10 @@ entry: store i32 %n, i32* %n.addr, align 4, !tbaa !0 %call = call noalias i8* @_Znwm(i64 8) %0 = bitcast i8* %call to %struct.Foo* - store %struct.Foo* %0, %struct.Foo** %f, align 8, !tbaa !3 - %1 = load %struct.Foo** %f, align 8, !tbaa !3 + store %struct.Foo* %0, %struct.Foo** %f, align 8, !tbaa !4 + %1 = load %struct.Foo** %f, align 8, !tbaa !4 %i = getelementptr inbounds %struct.Foo* %1, i32 0, i32 0 - store i64 1, i64* %i, align 8, !tbaa !4 + store i64 1, i64* %i, align 8, !tbaa !6 store i32 0, i32* %i1, align 4, !tbaa !0 br label %for.cond @@ -46,7 +46,7 @@ for.cond: br i1 %cmp, label %for.body, label %for.end for.body: - %4 = load %struct.Foo** %f, align 8, !tbaa !3 + %4 = load %struct.Foo** %f, align 8, !tbaa !4 %5 = bitcast %struct.Foo* %4 to i8* %new.isnull = icmp eq i8* %5, null br i1 %new.isnull, label %new.cont, label %new.notnull @@ -57,11 +57,11 @@ new.notnull: new.cont: %7 = phi %struct.Bar* [ %6, %new.notnull ], [ null, %for.body ] - store %struct.Bar* %7, %struct.Bar** %b, align 8, !tbaa !3 - %8 = load %struct.Bar** %b, align 8, !tbaa !3 + store %struct.Bar* %7, %struct.Bar** %b, align 8, !tbaa !4 + %8 = load %struct.Bar** %b, align 8, !tbaa !4 %p = getelementptr inbounds %struct.Bar* %8, i32 0, i32 0 - store i8* null, i8** %p, align 8, !tbaa !3 - %9 = load %struct.Foo** %f, align 8, !tbaa !3 + store i8* null, i8** %p, align 8, !tbaa !9 + %9 = load %struct.Foo** %f, align 8, !tbaa !4 %10 = bitcast %struct.Foo* %9 to i8* %new.isnull2 = icmp eq i8* %10, null br i1 %new.isnull2, label %new.cont4, label %new.notnull3 @@ -72,12 +72,12 @@ new.notnull3: new.cont4: %12 = phi %struct.Foo* [ %11, %new.notnull3 ], [ null, %new.cont ] - store %struct.Foo* %12, %struct.Foo** %f, align 8, !tbaa !3 + store %struct.Foo* %12, %struct.Foo** %f, align 8, !tbaa !4 %13 = load i32* %i1, align 4, !tbaa !0 %conv = sext i32 %13 to i64 - %14 = load %struct.Foo** %f, align 8, !tbaa !3 + %14 = load %struct.Foo** %f, align 8, !tbaa !4 %i5 = getelementptr inbounds %struct.Foo* %14, i32 0, i32 0 - store i64 %conv, i64* %i5, align 8, !tbaa !4 + store i64 %conv, i64* %i5, align 8, !tbaa !6 br label %for.inc for.inc: @@ -87,9 +87,9 @@ for.inc: br label %for.cond for.end: - %16 = load %struct.Foo** %f, align 8, !tbaa !3 + %16 = load %struct.Foo** %f, align 8, !tbaa !4 %i6 = getelementptr inbounds %struct.Foo* %16, i32 0, i32 0 - %17 = load i64* %i6, align 8, !tbaa !4 + %17 = load i64* %i6, align 8, !tbaa !6 ret i64 %17 } @@ -97,8 +97,14 @@ declare noalias i8* @_Znwm(i64) attributes #0 = { nounwind } -!0 = metadata !{metadata !"int", metadata !1} -!1 = metadata !{metadata !"omnipotent char", metadata !2} -!2 = metadata !{metadata !"Simple C/C++ TBAA"} -!3 = metadata !{metadata !"any pointer", metadata !1} -!4 = metadata !{metadata !"long", metadata !1} +!0 = metadata !{metadata !1, metadata !1, i64 0} +!1 = metadata !{metadata !"int", metadata !2, i64 0} +!2 = metadata !{metadata !"omnipotent char", metadata !3, i64 0} +!3 = metadata !{metadata !"Simple C/C++ TBAA"} +!4 = metadata !{metadata !5, metadata !5, i64 0} +!5 = metadata !{metadata !"any pointer", metadata !2, i64 0} +!6 = metadata !{metadata !7, metadata !8, i64 0} +!7 = metadata !{metadata !"_ZTS3Foo", metadata !8, i64 0} +!8 = metadata !{metadata !"long", metadata !2, i64 0} +!9 = metadata !{metadata !10, metadata !5, i64 0} +!10 = metadata !{metadata !"_ZTS3Bar", metadata !5, i64 0} diff --git a/test/Analysis/TypeBasedAliasAnalysis/precedence.ll b/test/Analysis/TypeBasedAliasAnalysis/precedence.ll index 47cb5f2256d38..b219ef19284e3 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/precedence.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/precedence.ll @@ -39,8 +39,12 @@ entry: ret i64 %tmp3 } -!0 = metadata !{metadata !"int", metadata !1} +!0 = metadata !{metadata !2, metadata !2, i64 0} !1 = metadata !{metadata !"simple"} -!3 = metadata !{metadata !"float", metadata !1} -!4 = metadata !{metadata !"long", metadata !1} -!5 = metadata !{metadata !"small", metadata !1} +!2 = metadata !{metadata !"int", metadata !1} +!3 = metadata !{metadata !6, metadata !6, i64 0} +!4 = metadata !{metadata !7, metadata !7, i64 0} +!5 = metadata !{metadata !8, metadata !8, i64 0} +!6 = metadata !{metadata !"float", metadata !1} +!7 = metadata !{metadata !"long", metadata !1} +!8 = metadata !{metadata !"small", metadata !1} diff --git a/test/Analysis/TypeBasedAliasAnalysis/sink.ll b/test/Analysis/TypeBasedAliasAnalysis/sink.ll index fd32d6a7a58ef..726da6ce1e816 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/sink.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/sink.ll @@ -1,7 +1,7 @@ ; RUN: opt -tbaa -sink -S < %s | FileCheck %s ; CHECK: a: -; CHECK: %f = load float* %p, !tbaa !2 +; CHECK: %f = load float* %p, !tbaa [[TAGA:!.*]] ; CHECK: store float %f, float* %q define void @foo(float* %p, i1 %c, float* %q, float* %r) { @@ -15,6 +15,10 @@ b: ret void } -!0 = metadata !{metadata !"A", metadata !2} -!1 = metadata !{metadata !"B", metadata !2} +; CHECK: [[TAGA]] = metadata !{metadata [[TYPEA:!.*]], metadata [[TYPEA]], i64 0} +; CHECK: [[TYPEA]] = metadata !{metadata !"A", metadata !{{.*}}} +!0 = metadata !{metadata !3, metadata !3, i64 0} +!1 = metadata !{metadata !4, metadata !4, i64 0} !2 = metadata !{metadata !"test"} +!3 = metadata !{metadata !"A", metadata !2} +!4 = metadata !{metadata !"B", metadata !2} diff --git a/test/Analysis/TypeBasedAliasAnalysis/tbaa-path.ll b/test/Analysis/TypeBasedAliasAnalysis/tbaa-path.ll index ee527639b3d10..0cd5c301842a0 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/tbaa-path.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/tbaa-path.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -tbaa -basicaa -struct-path-tbaa -aa-eval -evaluate-tbaa -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s -; RUN: opt < %s -tbaa -basicaa -struct-path-tbaa -gvn -S | FileCheck %s --check-prefix=OPT +; RUN: opt < %s -tbaa -basicaa -aa-eval -evaluate-tbaa -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s +; RUN: opt < %s -tbaa -basicaa -gvn -S | FileCheck %s --check-prefix=OPT ; Generated from clang/test/CodeGen/tbaa.cpp with "-O1 -struct-path-tbaa -disable-llvm-optzns". %struct.StructA = type { i16, i32, i16, i32 } |