1 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
2 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"
3 target triple = "x86_64-unknown-linux-gnu"
5 ; CHECK-LABEL: test_with_zext
6 ; CHECK: NoAlias: i8* %a, i8* %b
8 define void @test_with_zext() {
9 %1 = tail call i8* @malloc(i64 120)
10 %a = getelementptr inbounds i8, i8* %1, i64 8
11 %2 = getelementptr inbounds i8, i8* %1, i64 16
12 %3 = zext i32 3 to i64
13 %b = getelementptr inbounds i8, i8* %2, i64 %3
17 ; CHECK-LABEL: test_with_lshr
18 ; CHECK: NoAlias: i8* %a, i8* %b
20 define void @test_with_lshr(i64 %i) {
21 %1 = tail call i8* @malloc(i64 120)
22 %a = getelementptr inbounds i8, i8* %1, i64 8
23 %2 = getelementptr inbounds i8, i8* %1, i64 16
25 %b = getelementptr inbounds i8, i8* %2, i64 %3
29 ; CHECK-LABEL: test_with_a_loop
30 ; CHECK: NoAlias: i8* %a, i8* %b
32 define void @test_with_a_loop(i8* %mem) {
36 %i = phi i32 [ 0, %0 ], [ %i.plus1, %for.loop ]
37 %a = getelementptr inbounds i8, i8* %mem, i64 8
38 %a.plus1 = getelementptr inbounds i8, i8* %mem, i64 16
39 %i.64 = zext i32 %i to i64
40 %b = getelementptr inbounds i8, i8* %a.plus1, i64 %i.64
41 %i.plus1 = add nuw nsw i32 %i, 1
42 %cmp = icmp eq i32 %i.plus1, 10
43 br i1 %cmp, label %for.loop.exit, label %for.loop
49 ; CHECK-LABEL: test_with_varying_base_pointer_in_loop
50 ; CHECK: NoAlias: i8* %a, i8* %b
52 define void @test_with_varying_base_pointer_in_loop(i8* %mem.orig) {
56 %mem = phi i8* [ %mem.orig, %0 ], [ %mem.plus1, %for.loop ]
57 %i = phi i32 [ 0, %0 ], [ %i.plus1, %for.loop ]
58 %a = getelementptr inbounds i8, i8* %mem, i64 8
59 %a.plus1 = getelementptr inbounds i8, i8* %mem, i64 16
60 %i.64 = zext i32 %i to i64
61 %b = getelementptr inbounds i8, i8* %a.plus1, i64 %i.64
62 %i.plus1 = add nuw nsw i32 %i, 1
63 %mem.plus1 = getelementptr inbounds i8, i8* %mem, i64 8
64 %cmp = icmp eq i32 %i.plus1, 10
65 br i1 %cmp, label %for.loop.exit, label %for.loop
71 ; CHECK-LABEL: test_sign_extension
72 ; CHECK: MayAlias: i64* %b.i64, i8* %a
74 define void @test_sign_extension(i32 %p) {
75 %1 = tail call i8* @malloc(i64 120)
76 %p.64 = zext i32 %p to i64
77 %a = getelementptr inbounds i8, i8* %1, i64 %p.64
78 %p.minus1 = add i32 %p, -1
79 %p.minus1.64 = zext i32 %p.minus1 to i64
80 %b.i8 = getelementptr inbounds i8, i8* %1, i64 %p.minus1.64
81 %b.i64 = bitcast i8* %b.i8 to i64*
85 ; CHECK-LABEL: test_fe_tools
86 ; CHECK: MayAlias: i32* %a, i32* %b
88 define void @test_fe_tools([8 x i32]* %values) {
92 %i = phi i32 [ 0, %reorder ], [ %i.next, %for.loop ]
93 %idxprom = zext i32 %i to i64
94 %b = getelementptr inbounds [8 x i32], [8 x i32]* %values, i64 0, i64 %idxprom
95 %i.next = add nuw nsw i32 %i, 1
96 %1 = icmp eq i32 %i.next, 10
97 br i1 %1, label %for.loop.exit, label %for.loop
100 %a = getelementptr inbounds [8 x i32], [8 x i32]* %values, i64 0, i64 1
107 @b = global i32 0, align 4
108 @d = global i32 0, align 4
110 ; CHECK-LABEL: test_spec2006
111 ; CHECK: MayAlias: i32** %x, i32** %y
113 define void @test_spec2006() {
114 %h = alloca [1 x [2 x i32*]], align 16
115 %d.val = load i32, i32* @d, align 4
116 %d.promoted = sext i32 %d.val to i64
117 %1 = icmp slt i32 %d.val, 2
118 br i1 %1, label %.lr.ph, label %3
123 ; <label>:2 ; preds = %.lr.ph, %2
124 %i = phi i32 [ %d.val, %.lr.ph ], [ %i.plus1, %2 ]
125 %i.promoted = sext i32 %i to i64
126 %x = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 %d.promoted, i64 %i.promoted
127 %i.plus1 = add nsw i32 %i, 1
128 %cmp = icmp slt i32 %i.plus1, 2
129 br i1 %cmp, label %2, label %3
131 ; <label>:3 ; preds = %._crit_edge, %0
132 %y = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 0, i64 1
136 ; CHECK-LABEL: test_modulo_analysis_easy_case
137 ; CHECK: NoAlias: i32** %x, i32** %y
139 define void @test_modulo_analysis_easy_case(i64 %i) {
140 %h = alloca [1 x [2 x i32*]], align 16
141 %x = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 %i, i64 0
142 %y = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 0, i64 1
146 ; CHECK-LABEL: test_modulo_analysis_in_loop
147 ; CHECK: NoAlias: i32** %x, i32** %y
149 define void @test_modulo_analysis_in_loop() {
150 %h = alloca [1 x [2 x i32*]], align 16
154 %i = phi i32 [ 0, %0 ], [ %i.plus1, %for.loop ]
155 %i.promoted = sext i32 %i to i64
156 %x = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 %i.promoted, i64 0
157 %y = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 0, i64 1
158 %i.plus1 = add nsw i32 %i, 1
159 %cmp = icmp slt i32 %i.plus1, 2
160 br i1 %cmp, label %for.loop, label %for.loop.exit
166 ; CHECK-LABEL: test_modulo_analysis_with_global
167 ; CHECK: MayAlias: i32** %x, i32** %y
169 define void @test_modulo_analysis_with_global() {
170 %h = alloca [1 x [2 x i32*]], align 16
171 %b = load i32, i32* @b, align 4
172 %b.promoted = sext i32 %b to i64
176 %i = phi i32 [ 0, %0 ], [ %i.plus1, %for.loop ]
177 %i.promoted = sext i32 %i to i64
178 %x = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 %i.promoted, i64 %b.promoted
179 %y = getelementptr inbounds [1 x [2 x i32*]], [1 x [2 x i32*]]* %h, i64 0, i64 0, i64 1
180 %i.plus1 = add nsw i32 %i, 1
181 %cmp = icmp slt i32 %i.plus1, 2
182 br i1 %cmp, label %for.loop, label %for.loop.exit
188 ; CHECK-LABEL: test_const_eval
189 ; CHECK: NoAlias: i8* %a, i8* %b
190 define void @test_const_eval(i8* %ptr, i64 %offset) {
191 %a = getelementptr inbounds i8, i8* %ptr, i64 %offset
192 %a.dup = getelementptr inbounds i8, i8* %ptr, i64 %offset
193 %three = zext i32 3 to i64
194 %b = getelementptr inbounds i8, i8* %a.dup, i64 %three
198 ; CHECK-LABEL: test_const_eval_scaled
199 ; CHECK: MustAlias: i8* %a, i8* %b
200 define void @test_const_eval_scaled(i8* %ptr) {
201 %three = zext i32 3 to i64
202 %six = mul i64 %three, 2
203 %a = getelementptr inbounds i8, i8* %ptr, i64 %six
204 %b = getelementptr inbounds i8, i8* %ptr, i64 6
208 ; CHECK-LABEL: Function: foo
209 ; CHECK: MustAlias: float* %arrayidx, float* %arrayidx4.84
210 define float @foo(i32 *%A, float %rend, float** %wayar) {
212 %x0 = load i32, i32* %A, align 4
213 %conv = sext i32 %x0 to i64
214 %mul = shl nsw i64 %conv, 3
215 %call = tail call i8* @malloc(i64 %mul)
216 %x1 = bitcast i8* %call to float*
218 %sub = add nsw i32 %x0, -1
219 %idxprom = sext i32 %sub to i64
220 %arrayidx = getelementptr inbounds float, float* %x1, i64 %idxprom
221 store float %rend, float* %arrayidx, align 8
223 %indvars.iv76.83 = add nsw i64 %conv, -1
224 %arrayidx4.84 = getelementptr inbounds float, float* %x1, i64 %indvars.iv76.83
225 %x4 = load float, float* %arrayidx4.84, align 8
230 ; Function Attrs: nounwind
231 declare noalias i8* @malloc(i64)