[PATCH] D48023: [SLPVectorizer] Tidyup isShuffle helper
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 11 06:39:15 PDT 2018
RKSimon created this revision.
RKSimon added reviewers: ABataev, dtemirbulatov, spatel.
Ensure we keep track of the input vectors in all cases instead of just for SK_Alternate (this will be more useful once https://reviews.llvm.org/D47985 has landed).
Ideally we'd reuse the shuffle mask pattern matching in TargetTransformInfo::getInstructionThroughput here to easily add support for all TargetTransformInfo::ShuffleKind without mass code duplication, I've added a TODO for now.
Repository:
rL LLVM
https://reviews.llvm.org/D48023
Files:
lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -246,6 +246,8 @@
/// %ins4 = insertelement <4 x i8> %ins3, i8 %9, i32 3
/// ret <4 x i8> %ins4
/// InstCombiner transforms this into a shuffle and vector mul
+/// TODO: Can we split off and reuse the shuffle mask detection from
+/// TargetTransformInfo::getInstructionThroughput?
static Optional<TargetTransformInfo::ShuffleKind>
isShuffle(ArrayRef<Value *> VL) {
auto *EI0 = cast<ExtractElementInst>(VL[0]);
@@ -272,7 +274,11 @@
continue;
// For correct shuffling we have to have at most 2 different vector operands
// in all extractelement instructions.
- if (Vec1 && Vec2 && Vec != Vec1 && Vec != Vec2)
+ if (!Vec1 || Vec1 == Vec)
+ Vec1 = Vec;
+ else if (!Vec2 || Vec2 == Vec)
+ Vec2 = Vec;
+ else
return None;
if (CommonShuffleMode == Permute)
continue;
@@ -283,10 +289,6 @@
continue;
}
// Check the shuffle mode for the current operation.
- if (!Vec1)
- Vec1 = Vec;
- else if (Vec != Vec1)
- Vec2 = Vec;
// Example: shufflevector A, B, <0,5,2,7>
// I is odd and IntIdx for A == I - FirstAlternate shuffle.
// I is even and IntIdx for B == I - FirstAlternate shuffle.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48023.150739.patch
Type: text/x-patch
Size: 1432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180611/ea154e42/attachment.bin>
More information about the llvm-commits
mailing list