1 ; RUN: opt < %s -basicaa -gvn -instcombine -S |& FileCheck %s
3 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"
5 ; Make sure that basicaa thinks R and r are must aliases.
6 define i32 @test1(i8 * %P) {
8 %Q = bitcast i8* %P to {i32, i32}*
9 %R = getelementptr {i32, i32}* %Q, i32 0, i32 1
12 %q = bitcast i8* %P to {i32, i32}*
13 %r = getelementptr {i32, i32}* %q, i32 0, i32 1
22 define i32 @test2(i8 * %P) {
24 %Q = bitcast i8* %P to {i32, i32, i32}*
25 %R = getelementptr {i32, i32, i32}* %Q, i32 0, i32 1
28 %r = getelementptr {i32, i32, i32}* %Q, i32 0, i32 2
40 ; This was a miscompilation.
41 define i32 @test3({float, {i32, i32, i32}}* %P) {
43 %P2 = getelementptr {float, {i32, i32, i32}}* %P, i32 0, i32 1
44 %R = getelementptr {i32, i32, i32}* %P2, i32 0, i32 1
47 %r = getelementptr {i32, i32, i32}* %P2, i32 0, i32 2
59 ;; This is reduced from the SmallPtrSet constructor.
60 %SmallPtrSetImpl = type { i8**, i32, i32, i32, [1 x i8*] }
61 %SmallPtrSet64 = type { %SmallPtrSetImpl, [64 x i8*] }
63 define i32 @test4(%SmallPtrSet64* %P) {
65 %tmp2 = getelementptr inbounds %SmallPtrSet64* %P, i64 0, i32 0, i32 1
66 store i32 64, i32* %tmp2, align 8
67 %tmp3 = getelementptr inbounds %SmallPtrSet64* %P, i64 0, i32 0, i32 4, i64 64
68 store i8* null, i8** %tmp3, align 8
69 %tmp4 = load i32* %tmp2, align 8
76 define i32 @test5(i32* %p, i64 %i) {
77 %pi = getelementptr i32* %p, i64 %i
78 %i.next = add i64 %i, 1
79 %pi.next = getelementptr i32* %p, i64 %i.next
81 store i32 42, i32* %pi.next
90 define i32 @test6(i32* %p, i64 %i1) {
92 %pi = getelementptr i32* %p, i64 %i
93 %i.next = or i64 %i, 1
94 %pi.next = getelementptr i32* %p, i64 %i.next
96 store i32 42, i32* %pi.next
105 define i32 @test7(i32* %p, i64 %i) {
106 %pi = getelementptr i32* %p, i64 1
107 %i.next = shl i64 %i, 2
108 %pi.next = getelementptr i32* %p, i64 %i.next
110 store i32 42, i32* %pi.next
118 ; P[zext(i)] != p[zext(i+1)]
120 define i32 @test8(i32* %p, i16 %i) {
121 %i1 = zext i16 %i to i32
122 %pi = getelementptr i32* %p, i32 %i1
123 %i.next = add i16 %i, 1
124 %i.next2 = zext i16 %i.next to i32
125 %pi.next = getelementptr i32* %p, i32 %i.next2
127 store i32 42, i32* %pi.next
135 define i8 @test9([4 x i8] *%P, i32 %i, i32 %j) {
139 %P2 = getelementptr [4 x i8] *%P, i32 0, i32 %i3
144 %P4 = getelementptr [4 x i8]* %P, i32 0, i32 %j2
155 define i8 @test10([4 x i8] *%P, i32 %i) {
159 %P2 = getelementptr [4 x i8] *%P, i32 0, i32 %i3
162 %P4 = getelementptr [4 x i8]* %P, i32 0, i32 %i2