1 ; RUN: opt -basic-aa -aa-eval -print-all-alias-modref-info %s 2>&1 | FileCheck %s
3 ; %col.ptr.1 and %col.ptr.2 do not alias, if we know that %skip >= 0, because
4 ; the distance between %col.ptr.1 and %col.ptr.2 is %skip + 6 and we load 6
6 define void @test1(double* %ptr, i32 %skip) {
7 ; CHECK-LABEL: Function: test1: 4 pointers, 1 call sites
8 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.1, double* %ptr
9 ; CHECK-NEXT: NoAlias: double* %col.ptr.2, double* %ptr
10 ; CHECK-NEXT: NoAlias: <6 x double>* %col.ptr.1, double* %col.ptr.2
11 ; CHECK-NEXT: NoAlias: <6 x double>* %col.ptr.2.cast, double* %ptr
12 ; CHECK-NEXT: NoAlias: <6 x double>* %col.ptr.1, <6 x double>* %col.ptr.2.cast
13 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.2.cast, double* %col.ptr.2
14 ; CHECK-NEXT: NoModRef: Ptr: double* %ptr <-> call void @llvm.assume(i1 %gt)
15 ; CHECK-NEXT: NoModRef: Ptr: <6 x double>* %col.ptr.1 <-> call void @llvm.assume(i1 %gt)
16 ; CHECK-NEXT: NoModRef: Ptr: double* %col.ptr.2 <-> call void @llvm.assume(i1 %gt)
17 ; CHECK-NEXT: NoModRef: Ptr: <6 x double>* %col.ptr.2.cast <-> call void @llvm.assume(i1 %gt)
19 %gt = icmp sgt i32 %skip, -1
20 call void @llvm.assume(i1 %gt)
21 %stride = add nsw nuw i32 %skip, 6
22 %col.ptr.1 = bitcast double* %ptr to <6 x double>*
23 %lv.1 = load <6 x double>, <6 x double>* %col.ptr.1, align 8
24 %col.ptr.2= getelementptr double, double* %ptr, i32 %stride
25 %col.ptr.2.cast = bitcast double* %col.ptr.2 to <6 x double>*
26 %lv.2 = load <6 x double>, <6 x double>* %col.ptr.2.cast, align 8
27 %res.1 = fadd <6 x double> %lv.1, %lv.1
28 %res.2 = fadd <6 x double> %lv.2, %lv.2
29 store <6 x double> %res.1, <6 x double>* %col.ptr.1, align 8
30 store <6 x double> %res.2, <6 x double>* %col.ptr.2.cast, align 8
34 ; Same as @test1, but now we do not have an assume guaranteeing %skip >= 0.
35 define void @test2(double* %ptr, i32 %skip) {
36 ; CHECK-LABEL: Function: test2: 4 pointers, 0 call sites
37 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.1, double* %ptr
38 ; CHECK-NEXT: MayAlias: double* %col.ptr.2, double* %ptr
39 ; CHECK-NEXT: MayAlias: <6 x double>* %col.ptr.1, double* %col.ptr.2
40 ; CHECK-NEXT: MayAlias: <6 x double>* %col.ptr.2.cast, double* %ptr
41 ; CHECK-NEXT: MayAlias: <6 x double>* %col.ptr.1, <6 x double>* %col.ptr.2.cast
42 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.2.cast, double* %col.ptr.2
44 %stride = add nsw nuw i32 %skip, 6
45 %col.ptr.1 = bitcast double* %ptr to <6 x double>*
46 %lv.1 = load <6 x double>, <6 x double>* %col.ptr.1, align 8
47 %col.ptr.2= getelementptr double, double* %ptr, i32 %stride
48 %col.ptr.2.cast = bitcast double* %col.ptr.2 to <6 x double>*
49 %lv.2 = load <6 x double>, <6 x double>* %col.ptr.2.cast, align 8
50 %res.1 = fadd <6 x double> %lv.1, %lv.1
51 %res.2 = fadd <6 x double> %lv.2, %lv.2
52 store <6 x double> %res.1, <6 x double>* %col.ptr.1, align 8
53 store <6 x double> %res.2, <6 x double>* %col.ptr.2.cast, align 8
57 ; Same as @test1, but the assume just guarantees %skip > -3, which is not
58 ; enough to derive NoAlias
59 define void @test3(double* %ptr, i32 %skip) {
60 ; CHECK-LABEL: Function: test3: 4 pointers, 1 call sites
61 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.1, double* %ptr
62 ; CHECK-NEXT: MayAlias: double* %col.ptr.2, double* %ptr
63 ; CHECK-NEXT: MayAlias: <6 x double>* %col.ptr.1, double* %col.ptr.2
64 ; CHECK-NEXT: MayAlias: <6 x double>* %col.ptr.2.cast, double* %ptr
65 ; CHECK-NEXT: MayAlias: <6 x double>* %col.ptr.1, <6 x double>* %col.ptr.2.cast
66 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.2.cast, double* %col.ptr.2
67 ; CHECK-NEXT: NoModRef: Ptr: double* %ptr <-> call void @llvm.assume(i1 %gt)
68 ; CHECK-NEXT: NoModRef: Ptr: <6 x double>* %col.ptr.1 <-> call void @llvm.assume(i1 %gt)
69 ; CHECK-NEXT: NoModRef: Ptr: double* %col.ptr.2 <-> call void @llvm.assume(i1 %gt)
70 ; CHECK-NEXT: NoModRef: Ptr: <6 x double>* %col.ptr.2.cast <-> call void @llvm.assume(i1 %gt)
72 %gt = icmp sgt i32 %skip, -3
73 call void @llvm.assume(i1 %gt)
74 %stride = add nsw nuw i32 %skip, 6
75 %col.ptr.1 = bitcast double* %ptr to <6 x double>*
76 %lv.1 = load <6 x double>, <6 x double>* %col.ptr.1, align 8
77 %col.ptr.2= getelementptr double, double* %ptr, i32 %stride
78 %col.ptr.2.cast = bitcast double* %col.ptr.2 to <6 x double>*
79 %lv.2 = load <6 x double>, <6 x double>* %col.ptr.2.cast, align 8
80 %res.1 = fadd <6 x double> %lv.1, %lv.1
81 %res.2 = fadd <6 x double> %lv.2, %lv.2
82 store <6 x double> %res.1, <6 x double>* %col.ptr.1, align 8
83 store <6 x double> %res.2, <6 x double>* %col.ptr.2.cast, align 8
87 ; Same as @test1, but the assume uses the sge predicate for %skip >= 0.
88 define void @test4(double* %ptr, i32 %skip) {
89 ; CHECK-LABEL: Function: test4: 4 pointers, 1 call sites
90 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.1, double* %ptr
91 ; CHECK-NEXT: NoAlias: double* %col.ptr.2, double* %ptr
92 ; CHECK-NEXT: NoAlias: <6 x double>* %col.ptr.1, double* %col.ptr.2
93 ; CHECK-NEXT: NoAlias: <6 x double>* %col.ptr.2.cast, double* %ptr
94 ; CHECK-NEXT: NoAlias: <6 x double>* %col.ptr.1, <6 x double>* %col.ptr.2.cast
95 ; CHECK-NEXT: MustAlias: <6 x double>* %col.ptr.2.cast, double* %col.ptr.2
96 ; CHECK-NEXT: NoModRef: Ptr: double* %ptr <-> call void @llvm.assume(i1 %gt)
97 ; CHECK-NEXT: NoModRef: Ptr: <6 x double>* %col.ptr.1 <-> call void @llvm.assume(i1 %gt)
98 ; CHECK-NEXT: NoModRef: Ptr: double* %col.ptr.2 <-> call void @llvm.assume(i1 %gt)
99 ; CHECK-NEXT: NoModRef: Ptr: <6 x double>* %col.ptr.2.cast <-> call void @llvm.assume(i1 %gt)
101 %gt = icmp sge i32 %skip, 0
102 call void @llvm.assume(i1 %gt)
103 %stride = add nsw nuw i32 %skip, 6
104 %col.ptr.1 = bitcast double* %ptr to <6 x double>*
105 %lv.1 = load <6 x double>, <6 x double>* %col.ptr.1, align 8
106 %col.ptr.2= getelementptr double, double* %ptr, i32 %stride
107 %col.ptr.2.cast = bitcast double* %col.ptr.2 to <6 x double>*
108 %lv.2 = load <6 x double>, <6 x double>* %col.ptr.2.cast, align 8
109 %res.1 = fadd <6 x double> %lv.1, %lv.1
110 %res.2 = fadd <6 x double> %lv.2, %lv.2
111 store <6 x double> %res.1, <6 x double>* %col.ptr.1, align 8
112 store <6 x double> %res.2, <6 x double>* %col.ptr.2.cast, align 8
116 define void @symmetry([0 x i8]* %ptr, i32 %a, i32 %b, i32 %c) {
117 ; CHECK-LABEL: Function: symmetry
118 ; CHECK: NoAlias: i8* %gep1, i8* %gep2
120 %b.cmp = icmp slt i32 %b, 0
121 call void @llvm.assume(i1 %b.cmp)
122 %gep1 = getelementptr [0 x i8], [0 x i8]* %ptr, i32 %a, i32 %b
124 %c.cmp = icmp sgt i32 %c, -1
125 call void @llvm.assume(i1 %c.cmp)
126 %c.off = add nuw nsw i32 %c, 1
127 %gep2 = getelementptr [0 x i8], [0 x i8]* %ptr, i32 %a, i32 %c.off
131 declare void @llvm.assume(i1 %cond)
132 declare void @barrier()