[llvm-branch-commits] [llvm] dd07d60 - [SLP] Add test case showing a bug when dealing with padded types
Bjorn Pettersson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 12 07:40:15 PST 2021
Author: Bjorn Pettersson
Date: 2021-01-12T16:35:33+01:00
New Revision: dd07d60ec33969ae4f1e37500bb852563e142dfb
URL: https://github.com/llvm/llvm-project/commit/dd07d60ec33969ae4f1e37500bb852563e142dfb
DIFF: https://github.com/llvm/llvm-project/commit/dd07d60ec33969ae4f1e37500bb852563e142dfb.diff
LOG: [SLP] Add test case showing a bug when dealing with padded types
We shouldn't vectorize stores of non-packed types (i.e. types that
has padding between consecutive variables in a scalar layout,
but being packed in a vector layout).
The problem was detected as a miscompile in a downstream test case.
This is a pre-commit of a test case for the fix in D94446.
Added:
Modified:
llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll b/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
index b9fd032b5662..93a97c3c2405 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
@@ -15,8 +15,8 @@ define void @test1(x86_mmx %a, x86_mmx %b, i64* %ptr) {
; CHECK-NEXT: [[A_AND:%.*]] = and i64 [[A_CAST]], 42
; CHECK-NEXT: [[B_AND:%.*]] = and i64 [[B_CAST]], 42
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i64, i64* [[PTR:%.*]], i32 1
-; CHECK-NEXT: store i64 [[A_AND]], i64* [[PTR]]
-; CHECK-NEXT: store i64 [[B_AND]], i64* [[GEP]]
+; CHECK-NEXT: store i64 [[A_AND]], i64* [[PTR]], align 8
+; CHECK-NEXT: store i64 [[B_AND]], i64* [[GEP]], align 8
; CHECK-NEXT: ret void
;
entry:
@@ -110,3 +110,33 @@ bb1: ; preds = %entry
}
declare void @f(i64, i64)
+
+define void @test4(i32 %a, i28* %ptr) {
+; Check that we do not vectorize types that are padded to a bigger ones.
+; FIXME: This is not correct! See D94446.
+;
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 [[A:%.*]] to i28
+; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i28, i28* [[PTR:%.*]], i32 1
+; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i28, i28* [[PTR]], i32 2
+; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i28, i28* [[PTR]], i32 3
+; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i28> poison, i28 [[TRUNC]], i32 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i28> [[TMP0]], i28 [[TRUNC]], i32 1
+; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i28> [[TMP1]], i28 [[TRUNC]], i32 2
+; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i28> [[TMP2]], i28 [[TRUNC]], i32 3
+; CHECK-NEXT: [[TMP4:%.*]] = bitcast i28* [[PTR]] to <4 x i28>*
+; CHECK-NEXT: store <4 x i28> [[TMP3]], <4 x i28>* [[TMP4]], align 4
+; CHECK-NEXT: ret void
+;
+entry:
+ %trunc = trunc i32 %a to i28
+ %gep1 = getelementptr i28, i28* %ptr, i32 1
+ %gep2 = getelementptr i28, i28* %ptr, i32 2
+ %gep3 = getelementptr i28, i28* %ptr, i32 3
+ store i28 %trunc, i28* %ptr
+ store i28 %trunc, i28* %gep1
+ store i28 %trunc, i28* %gep2
+ store i28 %trunc, i28* %gep3
+ ret void
+}
More information about the llvm-branch-commits
mailing list