1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
4 @C.0.1248 = internal constant [128 x float] [ float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 ], align 32 ; <[128 x float]*> [#uses=1]
6 define float @test1(i32 %hash, float %x, float %y, float %z, float %w) {
9 ; CHECK-NEXT: [[TMP3:%.*]] = shl i32 [[HASH:%.*]], 2
10 ; CHECK-NEXT: [[TMP5:%.*]] = and i32 [[TMP3]], 124
11 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[TMP5]] to i64
12 ; CHECK-NEXT: [[TMP753:%.*]] = getelementptr [128 x float], [128 x float]* @C.0.1248, i64 0, i64 [[TMP0]]
13 ; CHECK-NEXT: [[TMP9:%.*]] = load float, float* [[TMP753]], align 16
14 ; CHECK-NEXT: [[TMP11:%.*]] = fmul float [[TMP9]], [[X:%.*]]
15 ; CHECK-NEXT: [[TMP13:%.*]] = fadd float [[TMP11]], 0.000000e+00
16 ; CHECK-NEXT: [[TMP17_SUM52:%.*]] = or i32 [[TMP5]], 1
17 ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[TMP17_SUM52]] to i64
18 ; CHECK-NEXT: [[TMP1851:%.*]] = getelementptr [128 x float], [128 x float]* @C.0.1248, i64 0, i64 [[TMP1]]
19 ; CHECK-NEXT: [[TMP19:%.*]] = load float, float* [[TMP1851]], align 4
20 ; CHECK-NEXT: [[TMP21:%.*]] = fmul float [[TMP19]], [[Y:%.*]]
21 ; CHECK-NEXT: [[TMP23:%.*]] = fadd float [[TMP21]], [[TMP13]]
22 ; CHECK-NEXT: [[TMP27_SUM50:%.*]] = or i32 [[TMP5]], 2
23 ; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP27_SUM50]] to i64
24 ; CHECK-NEXT: [[TMP2849:%.*]] = getelementptr [128 x float], [128 x float]* @C.0.1248, i64 0, i64 [[TMP2]]
25 ; CHECK-NEXT: [[TMP29:%.*]] = load float, float* [[TMP2849]], align 8
26 ; CHECK-NEXT: [[TMP31:%.*]] = fmul float [[TMP29]], [[Z:%.*]]
27 ; CHECK-NEXT: [[TMP33:%.*]] = fadd float [[TMP31]], [[TMP23]]
28 ; CHECK-NEXT: [[TMP37_SUM48:%.*]] = or i32 [[TMP5]], 3
29 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP37_SUM48]] to i64
30 ; CHECK-NEXT: [[TMP3847:%.*]] = getelementptr [128 x float], [128 x float]* @C.0.1248, i64 0, i64 [[TMP3]]
31 ; CHECK-NEXT: [[TMP39:%.*]] = load float, float* [[TMP3847]], align 4
32 ; CHECK-NEXT: [[TMP41:%.*]] = fmul float [[TMP39]], [[W:%.*]]
33 ; CHECK-NEXT: [[TMP43:%.*]] = fadd float [[TMP41]], [[TMP33]]
34 ; CHECK-NEXT: ret float [[TMP43]]
37 %lookupTable = alloca [128 x float], align 16 ; <[128 x float]*> [#uses=5]
38 %lookupTable1 = bitcast [128 x float]* %lookupTable to i8* ; <i8*> [#uses=1]
39 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 %lookupTable1, i8* align 16 bitcast ([128 x float]* @C.0.1248 to i8*), i64 512, i1 false)
42 %tmp3 = shl i32 %hash, 2 ; <i32> [#uses=1]
43 %tmp5 = and i32 %tmp3, 124 ; <i32> [#uses=4]
44 %tmp753 = getelementptr [128 x float], [128 x float]* %lookupTable, i32 0, i32 %tmp5 ; <float*> [#uses=1]
45 %tmp9 = load float, float* %tmp753 ; <float> [#uses=1]
46 %tmp11 = fmul float %tmp9, %x ; <float> [#uses=1]
47 %tmp13 = fadd float %tmp11, 0.000000e+00 ; <float> [#uses=1]
48 %tmp17.sum52 = or i32 %tmp5, 1 ; <i32> [#uses=1]
49 %tmp1851 = getelementptr [128 x float], [128 x float]* %lookupTable, i32 0, i32 %tmp17.sum52 ; <float*> [#uses=1]
50 %tmp19 = load float, float* %tmp1851 ; <float> [#uses=1]
51 %tmp21 = fmul float %tmp19, %y ; <float> [#uses=1]
52 %tmp23 = fadd float %tmp21, %tmp13 ; <float> [#uses=1]
53 %tmp27.sum50 = or i32 %tmp5, 2 ; <i32> [#uses=1]
54 %tmp2849 = getelementptr [128 x float], [128 x float]* %lookupTable, i32 0, i32 %tmp27.sum50 ; <float*> [#uses=1]
55 %tmp29 = load float, float* %tmp2849 ; <float> [#uses=1]
56 %tmp31 = fmul float %tmp29, %z ; <float> [#uses=1]
57 %tmp33 = fadd float %tmp31, %tmp23 ; <float> [#uses=1]
58 %tmp37.sum48 = or i32 %tmp5, 3 ; <i32> [#uses=1]
59 %tmp3847 = getelementptr [128 x float], [128 x float]* %lookupTable, i32 0, i32 %tmp37.sum48 ; <float*> [#uses=1]
60 %tmp39 = load float, float* %tmp3847 ; <float> [#uses=1]
61 %tmp41 = fmul float %tmp39, %w ; <float> [#uses=1]
62 %tmp43 = fadd float %tmp41, %tmp33 ; <float> [#uses=1]
66 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
67 declare void @llvm.memcpy.p1i8.p0i8.i64(i8 addrspace(1)* nocapture, i8* nocapture, i64, i1) nounwind
68 declare void @llvm.memcpy.p0i8.p1i8.i64(i8* nocapture, i8 addrspace(1)* nocapture, i64, i1) nounwind
69 declare void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* nocapture, i8 addrspace(1)* nocapture, i64, i1) nounwind
71 %T = type { i8, [123 x i8] }
72 %U = type { i32, i32, i32, i32, i32 }
74 @G = constant %T {i8 1, [123 x i8] zeroinitializer }
75 @H = constant [2 x %U] zeroinitializer, align 16
76 @I = internal addrspace(1) constant [4 x float] zeroinitializer , align 4
78 define void @test2() {
79 ; CHECK-LABEL: @test2(
80 ; CHECK-NEXT: [[B1:%.*]] = alloca [124 x i8], align 8
81 ; CHECK-NEXT: [[B1_SUB:%.*]] = getelementptr inbounds [124 x i8], [124 x i8]* [[B1]], i64 0, i64 0
82 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(124) [[B1_SUB]], i8* noundef nonnull align 16 dereferenceable(124) getelementptr inbounds (%T, %T* @G, i64 0, i32 0), i64 124, i1 false)
83 ; CHECK-NEXT: call void @bar(i8* nonnull [[B1_SUB]])
84 ; CHECK-NEXT: ret void
88 %a = bitcast %T* %A to i8*
89 %b = bitcast %T* %B to i8*
92 ; %A alloca is deleted
94 ; use @G instead of %A
95 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%T* @G to i8*), i64 124, i1 false)
96 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %b, i8* align 4 %a, i64 124, i1 false)
97 call void @bar(i8* %b)
101 define void @test2_no_null_opt() #0 {
102 ; CHECK-LABEL: @test2_no_null_opt(
103 ; CHECK-NEXT: [[B1:%.*]] = alloca [124 x i8], align 8
104 ; CHECK-NEXT: [[B1_SUB:%.*]] = getelementptr inbounds [124 x i8], [124 x i8]* [[B1]], i64 0, i64 0
105 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef align 8 dereferenceable(124) [[B1_SUB]], i8* noundef align 16 dereferenceable(124) getelementptr inbounds (%T, %T* @G, i64 0, i32 0), i64 124, i1 false)
106 ; CHECK-NEXT: call void @bar(i8* [[B1_SUB]])
107 ; CHECK-NEXT: ret void
111 %a = bitcast %T* %A to i8*
112 %b = bitcast %T* %B to i8*
115 ; %A alloca is deleted
117 ; use @G instead of %A
118 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%T* @G to i8*), i64 124, i1 false)
119 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %b, i8* align 4 %a, i64 124, i1 false)
120 call void @bar(i8* %b)
124 define void @test2_addrspacecast() {
125 ; CHECK-LABEL: @test2_addrspacecast(
126 ; CHECK-NEXT: [[B1:%.*]] = alloca [124 x i8], align 8
127 ; CHECK-NEXT: [[B1_SUB:%.*]] = getelementptr inbounds [124 x i8], [124 x i8]* [[B1]], i64 0, i64 0
128 ; CHECK-NEXT: [[B:%.*]] = addrspacecast i8* [[B1_SUB]] to i8 addrspace(1)*
129 ; CHECK-NEXT: call void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* noundef align 4 dereferenceable(124) [[B]], i8 addrspace(1)* noundef align 4 dereferenceable(124) addrspacecast (i8* getelementptr inbounds (%T, %T* @G, i64 0, i32 0) to i8 addrspace(1)*), i64 124, i1 false)
130 ; CHECK-NEXT: call void @bar_as1(i8 addrspace(1)* [[B]])
131 ; CHECK-NEXT: ret void
135 %a = addrspacecast %T* %A to i8 addrspace(1)*
136 %b = addrspacecast %T* %B to i8 addrspace(1)*
139 ; %A alloca is deleted
140 ; This doesn't exactly match what test2 does, because folding the type
141 ; cast into the alloca doesn't work for the addrspacecast yet.
143 ; use @G instead of %A
144 call void @llvm.memcpy.p1i8.p0i8.i64(i8 addrspace(1)* align 4 %a, i8* align 4 bitcast (%T* @G to i8*), i64 124, i1 false)
145 call void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* align 4 %b, i8 addrspace(1)* align 4 %a, i64 124, i1 false)
146 call void @bar_as1(i8 addrspace(1)* %b)
150 declare void @bar(i8*)
151 declare void @bar_as1(i8 addrspace(1)*)
154 ;; Should be able to eliminate the alloca.
155 define void @test3() {
156 ; CHECK-LABEL: @test3(
157 ; CHECK-NEXT: call void @bar(i8* getelementptr inbounds (%T, %T* @G, i64 0, i32 0)) [[ATTR2:#.*]]
158 ; CHECK-NEXT: ret void
161 %a = bitcast %T* %A to i8*
162 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%T* @G to i8*), i64 124, i1 false)
163 call void @bar(i8* %a) readonly
167 define void @test3_addrspacecast() {
168 ; CHECK-LABEL: @test3_addrspacecast(
169 ; CHECK-NEXT: call void @bar(i8* getelementptr inbounds (%T, %T* @G, i64 0, i32 0)) [[ATTR2]]
170 ; CHECK-NEXT: ret void
173 %a = bitcast %T* %A to i8*
174 call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %a, i8 addrspace(1)* align 4 addrspacecast (%T* @G to i8 addrspace(1)*), i64 124, i1 false)
175 call void @bar(i8* %a) readonly
180 define void @test4() {
181 ; CHECK-LABEL: @test4(
182 ; CHECK-NEXT: call void @baz(i8* byval(i8) getelementptr inbounds (%T, %T* @G, i64 0, i32 0))
183 ; CHECK-NEXT: ret void
186 %a = bitcast %T* %A to i8*
187 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%T* @G to i8*), i64 124, i1 false)
188 call void @baz(i8* byval(i8) %a)
192 declare void @llvm.lifetime.start.p0i8(i64, i8*)
193 define void @test5() {
194 ; CHECK-LABEL: @test5(
195 ; CHECK-NEXT: call void @baz(i8* byval(i8) getelementptr inbounds (%T, %T* @G, i64 0, i32 0))
196 ; CHECK-NEXT: ret void
199 %a = bitcast %T* %A to i8*
200 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %a)
201 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%T* @G to i8*), i64 124, i1 false)
202 call void @baz(i8* byval(i8) %a)
207 declare void @baz(i8* byval(i8))
210 define void @test6() {
211 ; CHECK-LABEL: @test6(
212 ; CHECK-NEXT: call void @bar(i8* bitcast ([2 x %U]* @H to i8*)) [[ATTR2]]
213 ; CHECK-NEXT: ret void
215 %A = alloca %U, align 16
216 %a = bitcast %U* %A to i8*
217 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 %a, i8* align 16 bitcast ([2 x %U]* @H to i8*), i64 20, i1 false)
218 call void @bar(i8* %a) readonly
222 define void @test7() {
223 ; CHECK-LABEL: @test7(
224 ; CHECK-NEXT: call void @bar(i8* bitcast ([2 x %U]* @H to i8*)) [[ATTR2]]
225 ; CHECK-NEXT: ret void
227 %A = alloca %U, align 16
228 %a = bitcast %U* %A to i8*
229 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%U* getelementptr ([2 x %U], [2 x %U]* @H, i64 0, i32 0) to i8*), i64 20, i1 false)
230 call void @bar(i8* %a) readonly
234 define void @test8() {
235 ; CHECK-LABEL: @test8(
236 ; CHECK-NEXT: [[AL:%.*]] = alloca [[U:%.*]], align 16
237 ; CHECK-NEXT: [[A:%.*]] = bitcast %U* [[AL]] to i8*
238 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(20) [[A]], i8* noundef nonnull align 4 dereferenceable(20) bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*), i64 20, i1 false)
239 ; CHECK-NEXT: call void @bar(i8* nonnull [[A]]) [[ATTR2]]
240 ; CHECK-NEXT: ret void
242 %al = alloca %U, align 16
243 %a = bitcast %U* %al to i8*
244 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%U* getelementptr ([2 x %U], [2 x %U]* @H, i64 0, i32 1) to i8*), i64 20, i1 false)
245 call void @bar(i8* %a) readonly
250 define void @test8_addrspacecast() {
251 ; CHECK-LABEL: @test8_addrspacecast(
252 ; CHECK-NEXT: [[AL:%.*]] = alloca [[U:%.*]], align 16
253 ; CHECK-NEXT: [[A:%.*]] = bitcast %U* [[AL]] to i8*
254 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p1i8.i64(i8* noundef nonnull align 16 dereferenceable(20) [[A]], i8 addrspace(1)* noundef align 4 dereferenceable(20) addrspacecast (i8* bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*) to i8 addrspace(1)*), i64 20, i1 false)
255 ; CHECK-NEXT: call void @bar(i8* nonnull [[A]]) [[ATTR2]]
256 ; CHECK-NEXT: ret void
258 %Al = alloca %U, align 16
259 %a = bitcast %U* %Al to i8*
260 call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %a, i8 addrspace(1)* align 4 addrspacecast (%U* getelementptr ([2 x %U], [2 x %U]* @H, i64 0, i32 1) to i8 addrspace(1)*), i64 20, i1 false)
261 call void @bar(i8* %a) readonly
265 define void @test9() {
266 ; CHECK-LABEL: @test9(
267 ; CHECK-NEXT: call void @bar(i8* bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*)) [[ATTR2]]
268 ; CHECK-NEXT: ret void
270 %A = alloca %U, align 4
271 %a = bitcast %U* %A to i8*
272 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a, i8* align 4 bitcast (%U* getelementptr ([2 x %U], [2 x %U]* @H, i64 0, i32 1) to i8*), i64 20, i1 false)
273 call void @bar(i8* %a) readonly
277 define void @test9_addrspacecast() {
278 ; CHECK-LABEL: @test9_addrspacecast(
279 ; CHECK-NEXT: call void @bar(i8* bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*)) [[ATTR2]]
280 ; CHECK-NEXT: ret void
282 %A = alloca %U, align 4
283 %a = bitcast %U* %A to i8*
284 call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %a, i8 addrspace(1)* align 4 addrspacecast (%U* getelementptr ([2 x %U], [2 x %U]* @H, i64 0, i32 1) to i8 addrspace(1)*), i64 20, i1 false)
285 call void @bar(i8* %a) readonly
289 @bbb = local_unnamed_addr global [1000000 x i8] zeroinitializer, align 16
290 @_ZL3KKK = internal unnamed_addr constant [3 x i8] c"\01\01\02", align 1
292 ; Should not replace alloca with global because of size mismatch.
293 define void @test9_small_global() {
294 ; CHECK-LABEL: @test9_small_global(
296 ; CHECK-NEXT: [[CC:%.*]] = alloca [1000000 x i8], align 16
297 ; CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1000000 x i8], [1000000 x i8]* [[CC]], i64 0, i64 0
298 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(3) [[ARRAYDECAY]], i8* noundef nonnull align 16 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i64 0, i64 0), i64 3, i1 false)
299 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(1000000) getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i64 0, i64 0), i8* noundef nonnull align 16 dereferenceable(1000000) [[ARRAYDECAY]], i64 1000000, i1 false)
300 ; CHECK-NEXT: ret void
303 %cc = alloca [1000000 x i8], align 16
304 %cc.0..sroa_idx = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %cc, i64 0, i64 0
305 %arraydecay = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %cc, i32 0, i32 0
306 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %arraydecay, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i32 0, i32 0), i64 3, i1 false)
307 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i32 0, i32 0), i8* align 16 %arraydecay, i64 1000000, i1 false)
311 ; Should replace alloca with global as they have exactly the same size.
312 define void @test10_same_global() {
313 ; CHECK-LABEL: @test10_same_global(
315 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(3) getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i64 0, i64 0), i8* noundef nonnull align 16 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i64 0, i64 0), i64 3, i1 false)
316 ; CHECK-NEXT: ret void
319 %cc = alloca [3 x i8], align 1
320 %cc.0..sroa_idx = getelementptr inbounds [3 x i8], [3 x i8]* %cc, i64 0, i64 0
321 %arraydecay = getelementptr inbounds [3 x i8], [3 x i8]* %cc, i32 0, i32 0
322 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %arraydecay, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i32 0, i32 0), i64 3, i1 false)
323 call void @llvm.memcpy.p0i8.p0i8.i64(i8* getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i32 0, i32 0), i8* %arraydecay, i64 3, i1 false)
327 ; Should replace alloca with global even when the global is in a different address space
328 define float @test11(i64 %i) {
329 ; CHECK-LABEL: @test11(
331 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr [4 x float], [4 x float] addrspace(1)* @I, i64 0, i64 %i
332 ; CHECK-NEXT: [[LD:%.*]] = load float, float addrspace(1)* [[GEP]]
333 ; CHECK-NEXT: ret float [[LD]]
336 %a = alloca [4 x float], align 4
337 %b = bitcast [4 x float]* %a to i8*
338 call void @llvm.lifetime.start.p0i8(i64 16, i8* %b)
339 call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %b, i8 addrspace(1)* align 4 bitcast ([4 x float] addrspace(1)* @I to i8 addrspace(1)*), i64 16, i1 false)
340 %g = getelementptr inbounds [4 x float], [4 x float]* %a, i64 0, i64 %i
341 %r = load float, float* %g, align 4
345 ; If the memcpy is volatile, it should not be removed
346 define float @test11_volatile(i64 %i) {
347 ; CHECK-LABEL: @test11_volatile(
350 ; CHECK: call void @llvm.lifetime.start.p0i8
351 ; CHECK: call void @llvm.memcpy
354 %a = alloca [4 x float], align 4
355 %b = bitcast [4 x float]* %a to i8*
356 call void @llvm.lifetime.start.p0i8(i64 16, i8* %b)
357 call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %b, i8 addrspace(1)* align 4 bitcast ([4 x float] addrspace(1)* @I to i8 addrspace(1)*), i64 16, i1 true)
358 %g = getelementptr inbounds [4 x float], [4 x float]* %a, i64 0, i64 %i
359 %r = load float, float* %g, align 4
363 attributes #0 = { null_pointer_is_valid }