1 ; RUN: opt -S -dse -enable-dse-partial-store-merging=false < %s | FileCheck %s
2 target datalayout = "E-m:e-i64:64-n32:64"
3 target triple = "powerpc64-bgq-linux"
5 %"struct.std::complex" = type { { float, float } }
7 define void @_Z4testSt7complexIfE(%"struct.std::complex"* noalias nocapture sret %agg.result, i64 %c.coerce) {
9 ; CHECK-LABEL: @_Z4testSt7complexIfE
11 %ref.tmp = alloca i64, align 8
12 %tmpcast = bitcast i64* %ref.tmp to %"struct.std::complex"*
13 %c.sroa.0.0.extract.shift = lshr i64 %c.coerce, 32
14 %c.sroa.0.0.extract.trunc = trunc i64 %c.sroa.0.0.extract.shift to i32
15 %0 = bitcast i32 %c.sroa.0.0.extract.trunc to float
16 %c.sroa.2.0.extract.trunc = trunc i64 %c.coerce to i32
17 %1 = bitcast i32 %c.sroa.2.0.extract.trunc to float
18 call void @_Z3barSt7complexIfE(%"struct.std::complex"* nonnull sret %tmpcast, i64 %c.coerce)
19 %2 = bitcast %"struct.std::complex"* %agg.result to i64*
20 %3 = load i64, i64* %ref.tmp, align 8
21 store i64 %3, i64* %2, align 4
22 ; CHECK-NOT: store i64
24 %_M_value.realp.i.i = getelementptr inbounds %"struct.std::complex", %"struct.std::complex"* %agg.result, i64 0, i32 0, i32 0
26 %5 = trunc i64 %4 to i32
27 %6 = bitcast i32 %5 to float
28 %_M_value.imagp.i.i = getelementptr inbounds %"struct.std::complex", %"struct.std::complex"* %agg.result, i64 0, i32 0, i32 1
29 %7 = trunc i64 %3 to i32
30 %8 = bitcast i32 %7 to float
31 %mul_ad.i.i = fmul fast float %6, %1
32 %mul_bc.i.i = fmul fast float %8, %0
33 %mul_i.i.i = fadd fast float %mul_ad.i.i, %mul_bc.i.i
34 %mul_ac.i.i = fmul fast float %6, %0
35 %mul_bd.i.i = fmul fast float %8, %1
36 %mul_r.i.i = fsub fast float %mul_ac.i.i, %mul_bd.i.i
37 store float %mul_r.i.i, float* %_M_value.realp.i.i, align 4
38 store float %mul_i.i.i, float* %_M_value.imagp.i.i, align 4
43 declare void @_Z3barSt7complexIfE(%"struct.std::complex"* sret, i64)
45 define void @test1(i32 *%ptr) {
49 store i32 5, i32* %ptr
50 %bptr = bitcast i32* %ptr to i8*
52 %wptr = bitcast i32* %ptr to i16*
53 store i16 -30062, i16* %wptr
54 %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2
55 store i8 25, i8* %bptr2
56 %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3
57 store i8 47, i8* %bptr3
58 %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1
59 %wptrp = bitcast i8* %bptr1 to i16*
60 store i16 2020, i16* %wptrp, align 1
63 ; CHECK-NOT: store i32 5, i32* %ptr
64 ; CHECK-NOT: store i8 7, i8* %bptr
65 ; CHECK: store i16 -30062, i16* %wptr
66 ; CHECK-NOT: store i8 25, i8* %bptr2
67 ; CHECK: store i8 47, i8* %bptr3
68 ; CHECK: store i16 2020, i16* %wptrp, align 1
73 define void @test2(i32 *%ptr) {
77 store i32 5, i32* %ptr
79 %bptr = bitcast i32* %ptr to i8*
80 %bptrm1 = getelementptr inbounds i8, i8* %bptr, i64 -1
81 %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1
82 %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2
83 %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3
85 %wptr = bitcast i8* %bptr to i16*
86 %wptrm1 = bitcast i8* %bptrm1 to i16*
87 %wptr1 = bitcast i8* %bptr1 to i16*
88 %wptr2 = bitcast i8* %bptr2 to i16*
89 %wptr3 = bitcast i8* %bptr3 to i16*
91 store i16 1456, i16* %wptrm1, align 1
92 store i16 1346, i16* %wptr, align 1
93 store i16 1756, i16* %wptr1, align 1
94 store i16 1126, i16* %wptr2, align 1
95 store i16 5656, i16* %wptr3, align 1
97 ; CHECK-NOT: store i32 5, i32* %ptr
99 ; CHECK: store i16 1456, i16* %wptrm1, align 1
100 ; CHECK: store i16 1346, i16* %wptr, align 1
101 ; CHECK: store i16 1756, i16* %wptr1, align 1
102 ; CHECK: store i16 1126, i16* %wptr2, align 1
103 ; CHECK: store i16 5656, i16* %wptr3, align 1
110 define signext i8 @test3(i32 *%ptr) {
112 ; CHECK-LABEL: @test3
114 store i32 5, i32* %ptr
116 %bptr = bitcast i32* %ptr to i8*
117 %bptrm1 = getelementptr inbounds i8, i8* %bptr, i64 -1
118 %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1
119 %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2
120 %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3
122 %wptr = bitcast i8* %bptr to i16*
123 %wptrm1 = bitcast i8* %bptrm1 to i16*
124 %wptr1 = bitcast i8* %bptr1 to i16*
125 %wptr2 = bitcast i8* %bptr2 to i16*
126 %wptr3 = bitcast i8* %bptr3 to i16*
128 %v = load i8, i8* %bptr, align 1
129 store i16 1456, i16* %wptrm1, align 1
130 store i16 1346, i16* %wptr, align 1
131 store i16 1756, i16* %wptr1, align 1
132 store i16 1126, i16* %wptr2, align 1
133 store i16 5656, i16* %wptr3, align 1
135 ; CHECK: store i32 5, i32* %ptr
142 %struct.foostruct = type {
143 i32 (i8*, i8**, i32, i8, i8*)*,
144 i32 (i8*, i8**, i32, i8, i8*)*,
145 i32 (i8*, i8**, i32, i8, i8*)*,
146 i32 (i8*, i8**, i32, i8, i8*)*,
147 void (i8*, i32, i32)*
149 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1)
150 declare void @goFunc(%struct.foostruct*)
151 declare i32 @fa(i8*, i8**, i32, i8, i8*)
153 define void @test4() {
155 ; CHECK-LABEL: @test4
157 %bang = alloca %struct.foostruct, align 8
158 %v1 = bitcast %struct.foostruct* %bang to i8*
159 call void @llvm.memset.p0i8.i64(i8* align 8 %v1, i8 0, i64 40, i1 false)
160 %v2 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 0
161 store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v2, align 8
162 %v3 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 1
163 store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v3, align 8
164 %v4 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 2
165 store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v4, align 8
166 %v5 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 3
167 store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v5, align 8
168 %v6 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 4
169 store void (i8*, i32, i32)* null, void (i8*, i32, i32)** %v6, align 8
170 call void @goFunc(%struct.foostruct* %bang)
177 define signext i8 @test5(i32 *%ptr) {
179 ; CHECK-LABEL: @test5
181 store i32 0, i32* %ptr
183 %bptr = bitcast i32* %ptr to i8*
184 %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1
185 %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2
186 %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3
188 %wptr = bitcast i8* %bptr to i16*
189 %wptr1 = bitcast i8* %bptr1 to i16*
190 %wptr2 = bitcast i8* %bptr2 to i16*
192 store i16 65535, i16* %wptr2, align 1
193 store i16 1456, i16* %wptr1, align 1
194 store i16 1346, i16* %wptr, align 1
196 ; CHECK-NOT: store i32 0, i32* %ptr
201 define signext i8 @test6(i32 *%ptr) {
203 ; CHECK-LABEL: @test6
205 store i32 0, i32* %ptr
207 %bptr = bitcast i32* %ptr to i16*
208 %bptr1 = getelementptr inbounds i16, i16* %bptr, i64 0
209 %bptr2 = getelementptr inbounds i16, i16* %bptr, i64 1
211 store i16 1456, i16* %bptr2, align 1
212 store i16 65535, i16* %bptr1, align 1
214 ; CHECK-NOT: store i32 0, i32* %ptr
219 define signext i8 @test7(i64 *%ptr) {
221 ; CHECK-LABEL: @test7
223 store i64 0, i64* %ptr
225 %bptr = bitcast i64* %ptr to i16*
226 %bptr1 = getelementptr inbounds i16, i16* %bptr, i64 0
227 %bptr2 = getelementptr inbounds i16, i16* %bptr, i64 1
228 %bptr3 = getelementptr inbounds i16, i16* %bptr, i64 2
229 %bptr4 = getelementptr inbounds i16, i16* %bptr, i64 3
231 store i16 1346, i16* %bptr1, align 1
232 store i16 1756, i16* %bptr3, align 1
233 store i16 1456, i16* %bptr2, align 1
234 store i16 5656, i16* %bptr4, align 1
236 ; CHECK-NOT: store i64 0, i64* %ptr