[PATCH] D94446: [SLP] Don't vectorize stores of non-packed types (like i1, i2)
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 02:31:31 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd58512b2e31a: [SLP] Don't vectorize stores of non-packed types (like i1, i2) (authored by bjope).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94446/new/
https://reviews.llvm.org/D94446
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
Index: llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
@@ -113,7 +113,6 @@
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:
@@ -121,12 +120,10 @@
; 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: store i28 [[TRUNC]], i28* [[PTR]], align 4
+; CHECK-NEXT: store i28 [[TRUNC]], i28* [[GEP1]], align 4
+; CHECK-NEXT: store i28 [[TRUNC]], i28* [[GEP2]], align 4
+; CHECK-NEXT: store i28 [[TRUNC]], i28* [[GEP3]], align 4
; CHECK-NEXT: ret void
;
entry:
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3094,6 +3094,16 @@
case Instruction::Store: {
// Check if the stores are consecutive or if we need to swizzle them.
llvm::Type *ScalarTy = cast<StoreInst>(VL0)->getValueOperand()->getType();
+ // Avoid types that are padded when being allocated as scalars, while
+ // being packed together in a vector (such as i1).
+ if (DL->getTypeSizeInBits(ScalarTy) !=
+ DL->getTypeAllocSizeInBits(ScalarTy)) {
+ BS.cancelScheduling(VL, VL0);
+ newTreeEntry(VL, None /*not vectorized*/, S, UserTreeIdx,
+ ReuseShuffleIndicies);
+ LLVM_DEBUG(dbgs() << "SLP: Gathering stores of non-packed type.\n");
+ return;
+ }
// Make sure all stores in the bundle are simple - we can't vectorize
// atomic or volatile stores.
SmallVector<Value *, 4> PointerOps(VL.size());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94446.316600.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210114/1d1aec8d/attachment.bin>
More information about the llvm-commits
mailing list