1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[X86][SSE] createVariablePermute - move index vector canonicalization to top of function. NFCI.

This is to make it easier to return early from the switch statement with custom lowering.

llvm-svn: 327140
This commit is contained in:
Simon Pilgrim 2018-03-09 15:48:56 +00:00
parent 47d2b317bb
commit 9e78cd8573

View File

@ -7914,9 +7914,19 @@ static SDValue materializeVectorConstant(SDValue Op, SelectionDAG &DAG,
SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
SDLoc &DL, SelectionDAG &DAG,
const X86Subtarget &Subtarget) {
unsigned Opcode = 0;
MVT ShuffleVT = VT;
EVT IndicesVT = EVT(VT).changeVectorElementTypeToInteger();
unsigned NumElts = VT.getVectorNumElements();
// Adjust IndicesVec to match VT size.
assert(IndicesVec.getValueType().getVectorNumElements() >= NumElts &&
"Illegal variable permute mask size");
if (IndicesVec.getValueType().getVectorNumElements() > NumElts)
IndicesVec = extractSubVector(IndicesVec, 0, DAG, SDLoc(IndicesVec),
NumElts * VT.getScalarSizeInBits());
IndicesVec = DAG.getZExtOrTrunc(IndicesVec, SDLoc(IndicesVec), IndicesVT);
unsigned Opcode = 0;
switch (VT.SimpleTy) {
default:
break;
@ -7994,16 +8004,6 @@ SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
(VT.getScalarSizeInBits() % ShuffleVT.getScalarSizeInBits()) == 0 &&
"Illegal variable permute shuffle type");
unsigned NumElts = VT.getVectorNumElements();
if (IndicesVec.getValueType().getVectorNumElements() < NumElts)
return SDValue();
else if (IndicesVec.getValueType().getVectorNumElements() > NumElts)
IndicesVec = extractSubVector(IndicesVec, 0, DAG, SDLoc(IndicesVec),
NumElts * VT.getScalarSizeInBits());
MVT IndicesVT = EVT(VT).changeVectorElementTypeToInteger().getSimpleVT();
IndicesVec = DAG.getZExtOrTrunc(IndicesVec, SDLoc(IndicesVec), IndicesVT);
if (SrcVec.getValueSizeInBits() > VT.getSizeInBits())
return SDValue();
else if (SrcVec.getValueSizeInBits() < VT.getSizeInBits()) {