• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
2
3; CHECK: Function: t1
4; CHECK: NoAlias: i32* %gep1, i32* %gep2
5define void @t1([8 x i32]* %p, i32 %addend, i32* %q) {
6  %knownnonzero = load i32, i32* %q, !range !0
7  %add = add nsw nuw i32 %addend, %knownnonzero
8  %gep1 = getelementptr [8 x i32], [8 x i32]* %p, i32 2, i32 %addend
9  %gep2 = getelementptr [8 x i32], [8 x i32]* %p, i32 2, i32 %add
10  ret void
11}
12
13; CHECK: Function: t2
14; CHECK: MayAlias: i32* %gep1, i32* %gep2
15define void @t2([8 x i32]* %p, i32 %addend, i32* %q) {
16  %knownnonzero = load i32, i32* %q, !range !0
17  %add = add nsw nuw i32 %addend, %knownnonzero
18  %gep1 = getelementptr [8 x i32], [8 x i32]* %p, i32 1, i32 %addend
19  %gep2 = getelementptr [8 x i32], [8 x i32]* %p, i32 0, i32 %add
20  ret void
21}
22
23; CHECK: Function: t3
24; CHECK: MustAlias: i32* %gep1, i32* %gep2
25define void @t3([8 x i32]* %p, i32 %addend, i32* %q) {
26  %knownnonzero = load i32, i32* %q, !range !0
27  %add = add nsw nuw i32 %addend, %knownnonzero
28  %gep1 = getelementptr [8 x i32], [8 x i32]* %p, i32 0, i32 %add
29  %gep2 = getelementptr [8 x i32], [8 x i32]* %p, i32 0, i32 %add
30  ret void
31}
32
33; CHECK: Function: t4
34; CHECK: MayAlias: i32* %gep1, i32* %gep2
35define void @t4([8 x i32]* %p, i32 %addend, i32* %q) {
36  %knownnonzero = load i32, i32* %q, !range !0
37  %add = add nsw nuw i32 %addend, %knownnonzero
38  %gep1 = getelementptr [8 x i32], [8 x i32]* %p, i32 1, i32 %addend
39  %gep2 = getelementptr [8 x i32], [8 x i32]* %p, i32 %add, i32 %add
40  ret void
41}
42
43; CHECK: Function: t5
44; CHECK: MayAlias: i32* %gep2, i64* %bc
45define void @t5([8 x i32]* %p, i32 %addend, i32* %q) {
46  %knownnonzero = load i32, i32* %q, !range !0
47  %add = add nsw nuw i32 %addend, %knownnonzero
48  %gep1 = getelementptr [8 x i32], [8 x i32]* %p, i32 2, i32 %addend
49  %gep2 = getelementptr [8 x i32], [8 x i32]* %p, i32 2, i32 %add
50  %bc = bitcast i32* %gep1 to i64*
51  ret void
52}
53
54; CHECK-LABEL: Function: add_non_zero_simple
55; CHECK: NoAlias: i32* %gep1, i32* %gep2
56define void @add_non_zero_simple(i32* %p, i32 %addend, i32* %q) {
57  %knownnonzero = load i32, i32* %q, !range !0
58  %add = add i32 %addend, %knownnonzero
59  %gep1 = getelementptr i32, i32* %p, i32 %addend
60  %gep2 = getelementptr i32, i32* %p, i32 %add
61  ret void
62}
63
64; CHECK-LABEL: Function: add_non_zero_different_scales
65; CHECK: MayAlias: i16* %gep2, i32* %gep1
66define void @add_non_zero_different_scales(i32* %p, i32 %addend, i32* %q) {
67  %knownnonzero = load i32, i32* %q, !range !0
68  %add = add i32 %addend, %knownnonzero
69  %p16 = bitcast i32* %p to i16*
70  %gep1 = getelementptr i32, i32* %p, i32 %addend
71  %gep2 = getelementptr i16, i16* %p16, i32 %add
72  ret void
73}
74
75; CHECK-LABEL: Function: add_non_zero_different_sizes
76; CHECK: NoAlias: i16* %gep1.16, i32* %gep2
77; CHECK: NoAlias: i16* %gep2.16, i32* %gep1
78; CHECK: NoAlias: i16* %gep1.16, i16* %gep2.16
79; CHECK: MayAlias: i32* %gep2, i64* %gep1.64
80; CHECK: MayAlias: i16* %gep2.16, i64* %gep1.64
81; CHECK: MayAlias: i32* %gep1, i64* %gep2.64
82; CHECK: MayAlias: i16* %gep1.16, i64* %gep2.64
83; CHECK: MayAlias: i64* %gep1.64, i64* %gep2.64
84define void @add_non_zero_different_sizes(i32* %p, i32 %addend, i32* %q) {
85  %knownnonzero = load i32, i32* %q, !range !0
86  %add = add i32 %addend, %knownnonzero
87  %gep1 = getelementptr i32, i32* %p, i32 %addend
88  %gep2 = getelementptr i32, i32* %p, i32 %add
89  %gep1.16 = bitcast i32* %gep1 to i16*
90  %gep2.16 = bitcast i32* %gep2 to i16*
91  %gep1.64 = bitcast i32* %gep1 to i64*
92  %gep2.64 = bitcast i32* %gep2 to i64*
93  ret void
94}
95
96
97; CHECK-LABEL: add_non_zero_with_offset
98; MayAlias: i32* %gep1, i32* %gep2
99; NoAlias: i16* %gep1.16, i16* %gep2.16
100define void @add_non_zero_with_offset(i32* %p, i32 %addend, i32* %q) {
101  %knownnonzero = load i32, i32* %q, !range !0
102  %add = add i32 %addend, %knownnonzero
103  %p.8 = bitcast i32* %p to i8*
104  %p.off.8 = getelementptr i8, i8* %p.8, i32 2
105  %p.off = bitcast i8* %p.off.8 to i32*
106  %gep1 = getelementptr i32, i32* %p.off, i32 %addend
107  %gep2 = getelementptr i32, i32* %p, i32 %add
108  %gep1.16 = bitcast i32* %gep1 to i16*
109  %gep2.16 = bitcast i32* %gep2 to i16*
110  ret void
111}
112
113!0 = !{ i32 1, i32 5 }
114