[llvm] r275708 - [X86][SSE] lowerVectorShuffleAsPermuteAndUnpack tidyup. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 17 08:48:26 PDT 2016
Author: rksimon
Date: Sun Jul 17 10:48:25 2016
New Revision: 275708
URL: http://llvm.org/viewvc/llvm-project?rev=275708&view=rev
Log:
[X86][SSE] lowerVectorShuffleAsPermuteAndUnpack tidyup. NFCI.
Moved unpack type determination into TryUnpack lambda.
Added missing comment describing lowerVectorShuffleAsPermuteAndUnpack call.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=275708&r1=275707&r2=275708&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Jul 17 10:48:25 2016
@@ -8803,9 +8803,9 @@ static SDValue lowerVectorShuffleAsPermu
bool UnpackLo = NumLoInputs >= NumHiInputs;
- auto TryUnpack = [&](MVT UnpackVT, int Scale) {
- SmallVector<int, 16> V1Mask(Mask.size(), -1);
- SmallVector<int, 16> V2Mask(Mask.size(), -1);
+ auto TryUnpack = [&](int ScalarSize, int Scale) {
+ SmallVector<int, 16> V1Mask((unsigned)Size, -1);
+ SmallVector<int, 16> V2Mask((unsigned)Size, -1);
for (int i = 0; i < Size; ++i) {
if (Mask[i] < 0)
@@ -8837,6 +8837,7 @@ static SDValue lowerVectorShuffleAsPermu
V2 = DAG.getVectorShuffle(VT, DL, V2, DAG.getUNDEF(VT), V2Mask);
// Cast the inputs to the type we will use to unpack them.
+ MVT UnpackVT = MVT::getVectorVT(MVT::getIntegerVT(ScalarSize), Size / Scale);
V1 = DAG.getBitcast(UnpackVT, V1);
V2 = DAG.getBitcast(UnpackVT, V2);
@@ -8848,15 +8849,10 @@ static SDValue lowerVectorShuffleAsPermu
// We try each unpack from the largest to the smallest to try and find one
// that fits this mask.
- int OrigNumElements = VT.getVectorNumElements();
int OrigScalarSize = VT.getScalarSizeInBits();
- for (int ScalarSize = 64; ScalarSize >= OrigScalarSize; ScalarSize /= 2) {
- int Scale = ScalarSize / OrigScalarSize;
- int NumElements = OrigNumElements / Scale;
- MVT UnpackVT = MVT::getVectorVT(MVT::getIntegerVT(ScalarSize), NumElements);
- if (SDValue Unpack = TryUnpack(UnpackVT, Scale))
+ for (int ScalarSize = 64; ScalarSize >= OrigScalarSize; ScalarSize /= 2)
+ if (SDValue Unpack = TryUnpack(ScalarSize, ScalarSize / OrigScalarSize))
return Unpack;
- }
// If none of the unpack-rooted lowerings worked (or were profitable) try an
// initial unpack.
@@ -9993,6 +9989,7 @@ static SDValue lowerV8I16VectorShuffle(c
lowerVectorShuffleAsBitBlend(DL, MVT::v8i16, V1, V2, Mask, DAG))
return BitBlend;
+ // Try to lower by permuting the inputs into an unpack instruction.
if (SDValue Unpack = lowerVectorShuffleAsPermuteAndUnpack(DL, MVT::v8i16, V1,
V2, Mask, DAG))
return Unpack;
More information about the llvm-commits
mailing list