Skip to content

Commit 4af373f

Browse files
committed
early return if target machine is big-endian
1 parent a4a7c9e commit 4af373f

File tree

2 files changed

+35
-69
lines changed

2 files changed

+35
-69
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
252252
uint64_t ScalarSizeInBytes = ScalarSize / 8;
253253
if (auto UnalignedBytes = Offset.urem(ScalarSizeInBytes);
254254
UnalignedBytes != 0) {
255+
if (DL->isBigEndian())
256+
return false;
255257
uint64_t OldScalarSizeInBytes = ScalarSizeInBytes;
256258
// Assign the greatest common divisor between UnalignedBytes and Offset to
257259
// ScalarSizeInBytes

llvm/test/Transforms/VectorCombine/X86/load.ll

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,11 @@ define <8 x i16> @gep01_load_i16_insert_v8i16_deref_minalign(ptr align 2 derefer
276276
}
277277

278278
define <4 x i32> @gep01_bitcast_load_i32_from_v16i8_insert_v4i32(ptr align 1 dereferenceable(16) %p) {
279-
; SSE2-LABEL: @gep01_bitcast_load_i32_from_v16i8_insert_v4i32(
280-
; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 1
281-
; SSE2-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
282-
; SSE2-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
283-
; SSE2-NEXT: ret <4 x i32> [[R]]
284-
;
285-
; AVX2-LABEL: @gep01_bitcast_load_i32_from_v16i8_insert_v4i32(
286-
; AVX2-NEXT: [[TMP1:%.*]] = load <16 x i8>, ptr [[P:%.*]], align 1
287-
; AVX2-NEXT: [[TMP2:%.*]] = shufflevector <16 x i8> [[TMP1]], <16 x i8> poison, <16 x i32> <i32 1, i32 2, i32 3, i32 4, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
288-
; AVX2-NEXT: [[R:%.*]] = bitcast <16 x i8> [[TMP2]] to <4 x i32>
289-
; AVX2-NEXT: ret <4 x i32> [[R]]
279+
; CHECK-LABEL: @gep01_bitcast_load_i32_from_v16i8_insert_v4i32(
280+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 1
281+
; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
282+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
283+
; CHECK-NEXT: ret <4 x i32> [[R]]
290284
;
291285
%gep = getelementptr inbounds <16 x i8>, ptr %p, i64 0, i64 1
292286
%s = load i32, ptr %gep, align 1
@@ -295,17 +289,11 @@ define <4 x i32> @gep01_bitcast_load_i32_from_v16i8_insert_v4i32(ptr align 1 der
295289
}
296290

297291
define <2 x i64> @gep01_bitcast_load_i64_from_v16i8_insert_v2i64(ptr align 1 dereferenceable(16) %p) {
298-
; SSE2-LABEL: @gep01_bitcast_load_i64_from_v16i8_insert_v2i64(
299-
; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 1
300-
; SSE2-NEXT: [[S:%.*]] = load i64, ptr [[GEP]], align 1
301-
; SSE2-NEXT: [[R:%.*]] = insertelement <2 x i64> undef, i64 [[S]], i64 0
302-
; SSE2-NEXT: ret <2 x i64> [[R]]
303-
;
304-
; AVX2-LABEL: @gep01_bitcast_load_i64_from_v16i8_insert_v2i64(
305-
; AVX2-NEXT: [[TMP1:%.*]] = load <16 x i8>, ptr [[P:%.*]], align 1
306-
; AVX2-NEXT: [[TMP2:%.*]] = shufflevector <16 x i8> [[TMP1]], <16 x i8> poison, <16 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
307-
; AVX2-NEXT: [[R:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
308-
; AVX2-NEXT: ret <2 x i64> [[R]]
292+
; CHECK-LABEL: @gep01_bitcast_load_i64_from_v16i8_insert_v2i64(
293+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 1
294+
; CHECK-NEXT: [[S:%.*]] = load i64, ptr [[GEP]], align 1
295+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i64> undef, i64 [[S]], i64 0
296+
; CHECK-NEXT: ret <2 x i64> [[R]]
309297
;
310298
%gep = getelementptr inbounds <16 x i8>, ptr %p, i64 0, i64 1
311299
%s = load i64, ptr %gep, align 1
@@ -314,17 +302,11 @@ define <2 x i64> @gep01_bitcast_load_i64_from_v16i8_insert_v2i64(ptr align 1 der
314302
}
315303

316304
define <4 x i32> @gep11_bitcast_load_i32_from_v16i8_insert_v4i32(ptr align 1 dereferenceable(16) %p) {
317-
; SSE2-LABEL: @gep11_bitcast_load_i32_from_v16i8_insert_v4i32(
318-
; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 11
319-
; SSE2-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
320-
; SSE2-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
321-
; SSE2-NEXT: ret <4 x i32> [[R]]
322-
;
323-
; AVX2-LABEL: @gep11_bitcast_load_i32_from_v16i8_insert_v4i32(
324-
; AVX2-NEXT: [[TMP1:%.*]] = load <16 x i8>, ptr [[P:%.*]], align 1
325-
; AVX2-NEXT: [[TMP2:%.*]] = shufflevector <16 x i8> [[TMP1]], <16 x i8> poison, <16 x i32> <i32 11, i32 12, i32 13, i32 14, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
326-
; AVX2-NEXT: [[R:%.*]] = bitcast <16 x i8> [[TMP2]] to <4 x i32>
327-
; AVX2-NEXT: ret <4 x i32> [[R]]
305+
; CHECK-LABEL: @gep11_bitcast_load_i32_from_v16i8_insert_v4i32(
306+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 11
307+
; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
308+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
309+
; CHECK-NEXT: ret <4 x i32> [[R]]
328310
;
329311
%gep = getelementptr inbounds <16 x i8>, ptr %p, i64 0, i64 11
330312
%s = load i32, ptr %gep, align 1
@@ -333,17 +315,11 @@ define <4 x i32> @gep11_bitcast_load_i32_from_v16i8_insert_v4i32(ptr align 1 der
333315
}
334316

335317
define <4 x i32> @gep01_bitcast_load_i32_from_v8i16_insert_v4i32(ptr align 1 dereferenceable(16) %p) {
336-
; SSE2-LABEL: @gep01_bitcast_load_i32_from_v8i16_insert_v4i32(
337-
; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1
338-
; SSE2-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
339-
; SSE2-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
340-
; SSE2-NEXT: ret <4 x i32> [[R]]
341-
;
342-
; AVX2-LABEL: @gep01_bitcast_load_i32_from_v8i16_insert_v4i32(
343-
; AVX2-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[P:%.*]], align 1
344-
; AVX2-NEXT: [[TMP2:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 1, i32 2, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
345-
; AVX2-NEXT: [[R:%.*]] = bitcast <8 x i16> [[TMP2]] to <4 x i32>
346-
; AVX2-NEXT: ret <4 x i32> [[R]]
318+
; CHECK-LABEL: @gep01_bitcast_load_i32_from_v8i16_insert_v4i32(
319+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1
320+
; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
321+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
322+
; CHECK-NEXT: ret <4 x i32> [[R]]
347323
;
348324
%gep = getelementptr inbounds <8 x i16>, ptr %p, i64 0, i64 1
349325
%s = load i32, ptr %gep, align 1
@@ -352,17 +328,11 @@ define <4 x i32> @gep01_bitcast_load_i32_from_v8i16_insert_v4i32(ptr align 1 der
352328
}
353329

354330
define <2 x i64> @gep01_bitcast_load_i64_from_v8i16_insert_v2i64(ptr align 1 dereferenceable(16) %p) {
355-
; SSE2-LABEL: @gep01_bitcast_load_i64_from_v8i16_insert_v2i64(
356-
; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1
357-
; SSE2-NEXT: [[S:%.*]] = load i64, ptr [[GEP]], align 1
358-
; SSE2-NEXT: [[R:%.*]] = insertelement <2 x i64> undef, i64 [[S]], i64 0
359-
; SSE2-NEXT: ret <2 x i64> [[R]]
360-
;
361-
; AVX2-LABEL: @gep01_bitcast_load_i64_from_v8i16_insert_v2i64(
362-
; AVX2-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[P:%.*]], align 1
363-
; AVX2-NEXT: [[TMP2:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 1, i32 2, i32 3, i32 4, i32 poison, i32 poison, i32 poison, i32 poison>
364-
; AVX2-NEXT: [[R:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
365-
; AVX2-NEXT: ret <2 x i64> [[R]]
331+
; CHECK-LABEL: @gep01_bitcast_load_i64_from_v8i16_insert_v2i64(
332+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1
333+
; CHECK-NEXT: [[S:%.*]] = load i64, ptr [[GEP]], align 1
334+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i64> undef, i64 [[S]], i64 0
335+
; CHECK-NEXT: ret <2 x i64> [[R]]
366336
;
367337
%gep = getelementptr inbounds <8 x i16>, ptr %p, i64 0, i64 1
368338
%s = load i64, ptr %gep, align 1
@@ -371,17 +341,11 @@ define <2 x i64> @gep01_bitcast_load_i64_from_v8i16_insert_v2i64(ptr align 1 der
371341
}
372342

373343
define <4 x i32> @gep05_bitcast_load_i32_from_v8i16_insert_v4i32(ptr align 1 dereferenceable(16) %p) {
374-
; SSE2-LABEL: @gep05_bitcast_load_i32_from_v8i16_insert_v4i32(
375-
; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 5
376-
; SSE2-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
377-
; SSE2-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
378-
; SSE2-NEXT: ret <4 x i32> [[R]]
379-
;
380-
; AVX2-LABEL: @gep05_bitcast_load_i32_from_v8i16_insert_v4i32(
381-
; AVX2-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[P:%.*]], align 1
382-
; AVX2-NEXT: [[TMP2:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 5, i32 6, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
383-
; AVX2-NEXT: [[R:%.*]] = bitcast <8 x i16> [[TMP2]] to <4 x i32>
384-
; AVX2-NEXT: ret <4 x i32> [[R]]
344+
; CHECK-LABEL: @gep05_bitcast_load_i32_from_v8i16_insert_v4i32(
345+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 5
346+
; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1
347+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
348+
; CHECK-NEXT: ret <4 x i32> [[R]]
385349
;
386350
%gep = getelementptr inbounds <8 x i16>, ptr %p, i64 0, i64 5
387351
%s = load i32, ptr %gep, align 1
@@ -391,9 +355,9 @@ define <4 x i32> @gep05_bitcast_load_i32_from_v8i16_insert_v4i32(ptr align 1 der
391355

392356
define <2 x i64> @gep01_bitcast_load_i32_from_v4i32_insert_v2i64(ptr align 1 dereferenceable(16) %p) {
393357
; CHECK-LABEL: @gep01_bitcast_load_i32_from_v4i32_insert_v2i64(
394-
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[P:%.*]], align 1
395-
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> <i32 1, i32 2, i32 poison, i32 poison>
396-
; CHECK-NEXT: [[R:%.*]] = bitcast <4 x i32> [[TMP2]] to <2 x i64>
358+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <4 x i32>, ptr [[P:%.*]], i64 0, i64 1
359+
; CHECK-NEXT: [[S:%.*]] = load i64, ptr [[GEP]], align 1
360+
; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i64> undef, i64 [[S]], i64 0
397361
; CHECK-NEXT: ret <2 x i64> [[R]]
398362
;
399363
%gep = getelementptr inbounds <4 x i32>, ptr %p, i64 0, i64 1

0 commit comments

Comments
 (0)