You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[InstCombine] Bail out of load-store forwarding for scalable vector types
This patch fixes an invalid TypeSize->uint64_t implicit conversion in
FoldReinterpretLoadFromConst. If the size of the constant is scalable
we bail out of the optimisation for now.
Tests added here:
Transforms/InstCombine/load-store-forward.ll
Differential Revision: https://reviews.llvm.org/D120240
(cherry picked from commit 47eff64)
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <vscale x 4 x i32>*
128
+
; CHECK-NEXT: store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 1, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* [[TMP0]], align 16
store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i321, i640), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* %0, align16
135
+
%1 = loadi32, i32*%a, align4
136
+
reti32%1
137
+
}
138
+
139
+
definei64@load_i64_store_nxv8i8(i8*%a) {
140
+
; CHECK-LABEL: @load_i64_store_nxv8i8(
141
+
; CHECK-NEXT: entry:
142
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[A:%.*]] to <vscale x 8 x i8>*
143
+
; CHECK-NEXT: store <vscale x 8 x i8> shufflevector (<vscale x 8 x i8> insertelement (<vscale x 8 x i8> poison, i8 1, i32 0), <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer), <vscale x 8 x i8>* [[TMP0]], align 16
144
+
; CHECK-NEXT: [[A2:%.*]] = bitcast i8* [[A]] to i64*
store <vscale x 8 x i8> shufflevector (<vscale x 8 x i8> insertelement (<vscale x 8 x i8> poison, i81, i320), <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer), <vscale x 8 x i8>* %0, align16
151
+
%a2 = bitcasti8*%atoi64*
152
+
%load = loadi64, i64*%a2, align8
153
+
reti64%load
154
+
}
155
+
156
+
definei64@load_i64_store_nxv4i32(i32*%a) {
157
+
; CHECK-LABEL: @load_i64_store_nxv4i32(
158
+
; CHECK-NEXT: entry:
159
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <vscale x 4 x i32>*
160
+
; CHECK-NEXT: store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 1, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* [[TMP0]], align 16
161
+
; CHECK-NEXT: [[A2:%.*]] = bitcast i32* [[A]] to i64*
store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i321, i640), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* %0, align16
168
+
%a2 = bitcasti32*%atoi64*
169
+
%load = loadi64, i64*%a2, align8
170
+
reti64%load
171
+
}
172
+
173
+
definei8@load_i8_store_nxv4i32(i32*%a) {
174
+
; CHECK-LABEL: @load_i8_store_nxv4i32(
175
+
; CHECK-NEXT: entry:
176
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <vscale x 4 x i32>*
177
+
; CHECK-NEXT: store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 1, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* [[TMP0]], align 16
178
+
; CHECK-NEXT: [[A2:%.*]] = bitcast i32* [[A]] to i8*
store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i321, i640), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* %0, align16
185
+
%a2 = bitcasti32*%atoi8*
186
+
%load = loadi8, i8*%a2, align1
187
+
reti8%load
188
+
}
189
+
190
+
definefloat@load_f32_store_nxv4f32(float* %a) {
191
+
; CHECK-LABEL: @load_f32_store_nxv4f32(
192
+
; CHECK-NEXT: entry:
193
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast float* [[A:%.*]] to <vscale x 4 x float>*
194
+
; CHECK-NEXT: store <vscale x 4 x float> shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float 1.000000e+00, i64 0), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x float>* [[TMP0]], align 16
store <vscale x 4 x float> shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float1.0, i640), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x float>* %0, align16
201
+
%1 = loadfloat, float* %a, align4
202
+
retfloat%1
203
+
}
204
+
205
+
definei32@load_i32_store_nxv4f32(float* %a) {
206
+
; CHECK-LABEL: @load_i32_store_nxv4f32(
207
+
; CHECK-NEXT: entry:
208
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast float* [[A:%.*]] to <vscale x 4 x float>*
209
+
; CHECK-NEXT: store <vscale x 4 x float> shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float 1.000000e+00, i64 0), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x float>* [[TMP0]], align 16
210
+
; CHECK-NEXT: [[A2:%.*]] = bitcast float* [[A]] to i32*
store <vscale x 4 x float> shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float1.0, i640), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x float>* %0, align16
217
+
%a2 = bitcastfloat* %atoi32*
218
+
%load = loadi32, i32*%a2, align4
219
+
reti32%load
220
+
}
221
+
222
+
define <4 x i32> @load_v4i32_store_nxv4i32(i32*%a) {
223
+
; CHECK-LABEL: @load_v4i32_store_nxv4i32(
224
+
; CHECK-NEXT: entry:
225
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <vscale x 4 x i32>*
226
+
; CHECK-NEXT: store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 1, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* [[TMP0]], align 16
227
+
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to <4 x i32>*
228
+
; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 16
229
+
; CHECK-NEXT: ret <4 x i32> [[TMP2]]
230
+
;
231
+
entry:
232
+
%0 = bitcasti32*%ato <vscale x 4 x i32>*
233
+
store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i321, i640), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* %0, align16
234
+
%1 = bitcasti32*%ato <4 x i32>*
235
+
%2 = load <4 x i32>, <4 x i32>* %1, align16
236
+
ret <4 x i32> %2
237
+
}
238
+
239
+
define <4 x i16> @load_v4i16_store_nxv4i32(i32*%a) {
240
+
; CHECK-LABEL: @load_v4i16_store_nxv4i32(
241
+
; CHECK-NEXT: entry:
242
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <vscale x 4 x i32>*
243
+
; CHECK-NEXT: store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 1, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* [[TMP0]], align 16
244
+
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to <4 x i16>*
245
+
; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i16>, <4 x i16>* [[TMP1]], align 16
246
+
; CHECK-NEXT: ret <4 x i16> [[TMP2]]
247
+
;
248
+
entry:
249
+
%0 = bitcasti32*%ato <vscale x 4 x i32>*
250
+
store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i321, i640), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* %0, align16
251
+
%1 = bitcasti32*%ato <4 x i16>*
252
+
%2 = load <4 x i16>, <4 x i16>* %1, align16
253
+
ret <4 x i16> %2
254
+
}
255
+
256
+
; Loaded data type exceeds the known minimum size of the store.
257
+
definei64@load_i64_store_nxv4i8(i8*%a) {
258
+
; CHECK-LABEL: @load_i64_store_nxv4i8(
259
+
; CHECK-NEXT: entry:
260
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[A:%.*]] to <vscale x 4 x i8>*
261
+
; CHECK-NEXT: store <vscale x 4 x i8> shufflevector (<vscale x 4 x i8> insertelement (<vscale x 4 x i8> poison, i8 1, i32 0), <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i8>* [[TMP0]], align 16
262
+
; CHECK-NEXT: [[A2:%.*]] = bitcast i8* [[A]] to i64*
store <vscale x 4 x i8> shufflevector (<vscale x 4 x i8> insertelement (<vscale x 4 x i8> poison, i81, i320), <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i8>* %0, align16
269
+
%a2 = bitcasti8*%atoi64*
270
+
%load = loadi64, i64*%a2, align8
271
+
reti64%load
272
+
}
273
+
274
+
; Loaded data size is unknown - we cannot guarantee it won't
275
+
; exceed the store size.
276
+
define <vscale x 4 x i8> @load_nxv4i8_store_nxv4i32(i32*%a) {
277
+
; CHECK-LABEL: @load_nxv4i8_store_nxv4i32(
278
+
; CHECK-NEXT: entry:
279
+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <vscale x 4 x i32>*
280
+
; CHECK-NEXT: store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 1, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* [[TMP0]], align 16
281
+
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to <vscale x 4 x i8>*
282
+
; CHECK-NEXT: [[TMP2:%.*]] = load <vscale x 4 x i8>, <vscale x 4 x i8>* [[TMP1]], align 16
283
+
; CHECK-NEXT: ret <vscale x 4 x i8> [[TMP2]]
284
+
;
285
+
entry:
286
+
%0 = bitcasti32*%ato <vscale x 4 x i32>*
287
+
store <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i321, i640), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32>* %0, align16
288
+
%1 = bitcasti32*%ato <vscale x 4 x i8>*
289
+
%2 = load <vscale x 4 x i8>, <vscale x 4 x i8>* %1, align16
0 commit comments