[llvm] r314658 - [X86][SSE] Add createPackShuffleMask helper function. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 03:12:51 PDT 2017
Author: rksimon
Date: Mon Oct 2 03:12:51 2017
New Revision: 314658
URL: http://llvm.org/viewvc/llvm-project?rev=314658&view=rev
Log:
[X86][SSE] Add createPackShuffleMask helper function. NFCI.
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=314658&r1=314657&r2=314658&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Oct 2 03:12:51 2017
@@ -5444,6 +5444,24 @@ static bool getTargetShuffleMaskIndices(
return true;
}
+/// Create a shuffle mask that matches the PACKSS/PACKUS truncation.
+/// Note: This ignores saturation, so inputs must be checked first.
+static void createPackShuffleMask(MVT VT, SmallVectorImpl<int> &Mask,
+ bool Unary) {
+ assert(Mask.empty() && "Expected an empty shuffle mask vector");
+ int NumElts = VT.getVectorNumElements();
+ int NumLanes = VT.getSizeInBits() / 128;
+ int NumEltsPerLane = 128 / VT.getScalarSizeInBits();
+ int Offset = Unary ? 0 : NumElts;
+
+ for (unsigned Lane = 0; Lane != NumLanes; ++Lane) {
+ for (unsigned Elt = 0; Elt != NumEltsPerLane; Elt += 2)
+ Mask.push_back(Elt + (Lane * NumEltsPerLane));
+ for (unsigned Elt = 0; Elt != NumEltsPerLane; Elt += 2)
+ Mask.push_back(Elt + (Lane * NumEltsPerLane) + Offset);
+ }
+}
+
/// Calculates the shuffle mask corresponding to the target-specific opcode.
/// If the mask could be calculated, returns it in \p Mask, returns the shuffle
/// operands in \p Ops, and returns true.
@@ -5953,21 +5971,12 @@ static bool getFauxShuffleMask(SDValue N
}
bool IsUnary = (N0 == N1);
- unsigned Offset = IsUnary ? 0 : NumElts;
- unsigned NumLanes = VT.getSizeInBits() / 128;
- unsigned NumEltsPerLane = NumElts / NumLanes;
- unsigned HalfEltsPerLane = NumEltsPerLane / 2;
Ops.push_back(N0);
if (!IsUnary)
Ops.push_back(N1);
- for (unsigned Lane = 0; Lane != NumLanes; ++Lane) {
- for (unsigned Elt = 0; Elt != HalfEltsPerLane; ++Elt)
- Mask.push_back((Elt * 2) + (Lane * NumEltsPerLane));
- for (unsigned Elt = 0; Elt != HalfEltsPerLane; ++Elt)
- Mask.push_back((Elt * 2) + (Lane * NumEltsPerLane) + Offset);
- }
+ createPackShuffleMask(VT, Mask, IsUnary);
return true;
}
case X86ISD::VSHLI:
More information about the llvm-commits
mailing list