1; RUN: opt -basicaa -gvn -S < %s | FileCheck %s 2 3define i32 @test1(i32* %p) { 4; CHECK: @test1(i32* %p) 5; CHECK: %a = load i32* %p, !range !0 6; CHECK: %c = add i32 %a, %a 7 %a = load i32* %p, !range !0 8 %b = load i32* %p, !range !0 9 %c = add i32 %a, %b 10 ret i32 %c 11} 12 13define i32 @test2(i32* %p) { 14; CHECK: @test2(i32* %p) 15; CHECK: %a = load i32* %p 16; CHECK-NOT: range 17; CHECK: %c = add i32 %a, %a 18 %a = load i32* %p, !range !0 19 %b = load i32* %p 20 %c = add i32 %a, %b 21 ret i32 %c 22} 23 24define i32 @test3(i32* %p) { 25; CHECK: @test3(i32* %p) 26; CHECK: %a = load i32* %p, !range ![[DISJOINT_RANGE:[0-9]+]] 27; CHECK: %c = add i32 %a, %a 28 %a = load i32* %p, !range !0 29 %b = load i32* %p, !range !1 30 %c = add i32 %a, %b 31 ret i32 %c 32} 33 34define i32 @test4(i32* %p) { 35; CHECK: @test4(i32* %p) 36; CHECK: %a = load i32* %p, !range ![[MERGED_RANGE:[0-9]+]] 37; CHECK: %c = add i32 %a, %a 38 %a = load i32* %p, !range !0 39 %b = load i32* %p, !range !2 40 %c = add i32 %a, %b 41 ret i32 %c 42} 43 44define i32 @test5(i32* %p) { 45; CHECK: @test5(i32* %p) 46; CHECK: %a = load i32* %p, !range ![[MERGED_SIGNED_RANGE:[0-9]+]] 47; CHECK: %c = add i32 %a, %a 48 %a = load i32* %p, !range !3 49 %b = load i32* %p, !range !4 50 %c = add i32 %a, %b 51 ret i32 %c 52} 53 54define i32 @test6(i32* %p) { 55; CHECK: @test6(i32* %p) 56; CHECK: %a = load i32* %p, !range ![[MERGED_TEST6:[0-9]+]] 57; CHECK: %c = add i32 %a, %a 58 %a = load i32* %p, !range !5 59 %b = load i32* %p, !range !6 60 %c = add i32 %a, %b 61 ret i32 %c 62} 63 64define i32 @test7(i32* %p) { 65; CHECK: @test7(i32* %p) 66; CHECK: %a = load i32* %p, !range ![[MERGED_TEST7:[0-9]+]] 67; CHECK: %c = add i32 %a, %a 68 %a = load i32* %p, !range !7 69 %b = load i32* %p, !range !8 70 %c = add i32 %a, %b 71 ret i32 %c 72} 73 74define i32 @test8(i32* %p) { 75; CHECK: @test8(i32* %p) 76; CHECK: %a = load i32* %p 77; CHECK-NOT: range 78; CHECK: %c = add i32 %a, %a 79 %a = load i32* %p, !range !9 80 %b = load i32* %p, !range !10 81 %c = add i32 %a, %b 82 ret i32 %c 83} 84 85; CHECK: ![[DISJOINT_RANGE]] = metadata !{i32 0, i32 2, i32 3, i32 5} 86; CHECK: ![[MERGED_RANGE]] = metadata !{i32 0, i32 5} 87; CHECK: ![[MERGED_SIGNED_RANGE]] = metadata !{i32 -3, i32 -2, i32 1, i32 2} 88; CHECK: ![[MERGED_TEST6]] = metadata !{i32 10, i32 1} 89; CHECK: ![[MERGED_TEST7]] = metadata !{i32 3, i32 4, i32 5, i32 2} 90 91!0 = metadata !{i32 0, i32 2} 92!1 = metadata !{i32 3, i32 5} 93!2 = metadata !{i32 2, i32 5} 94!3 = metadata !{i32 -3, i32 -2} 95!4 = metadata !{i32 1, i32 2} 96!5 = metadata !{i32 10, i32 1} 97!6 = metadata !{i32 12, i32 13} 98!7 = metadata !{i32 1, i32 2, i32 3, i32 4} 99!8 = metadata !{i32 5, i32 1} 100!9 = metadata !{i32 1, i32 5} 101!10 = metadata !{i32 5, i32 1} 102