@@ -7914,9 +7914,19 @@ static SDValue materializeVectorConstant(SDValue Op, SelectionDAG &DAG,
7914
7914
SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
7915
7915
SDLoc &DL, SelectionDAG &DAG,
7916
7916
const X86Subtarget &Subtarget) {
7917
- unsigned Opcode = 0;
7918
7917
MVT ShuffleVT = VT;
7918
+ EVT IndicesVT = EVT(VT).changeVectorElementTypeToInteger();
7919
+ unsigned NumElts = VT.getVectorNumElements();
7919
7920
7921
+ // Adjust IndicesVec to match VT size.
7922
+ assert(IndicesVec.getValueType().getVectorNumElements() >= NumElts &&
7923
+ "Illegal variable permute mask size");
7924
+ if (IndicesVec.getValueType().getVectorNumElements() > NumElts)
7925
+ IndicesVec = extractSubVector(IndicesVec, 0, DAG, SDLoc(IndicesVec),
7926
+ NumElts * VT.getScalarSizeInBits());
7927
+ IndicesVec = DAG.getZExtOrTrunc(IndicesVec, SDLoc(IndicesVec), IndicesVT);
7928
+
7929
+ unsigned Opcode = 0;
7920
7930
switch (VT.SimpleTy) {
7921
7931
default:
7922
7932
break;
@@ -7994,16 +8004,6 @@ SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
7994
8004
(VT.getScalarSizeInBits() % ShuffleVT.getScalarSizeInBits()) == 0 &&
7995
8005
"Illegal variable permute shuffle type");
7996
8006
7997
- unsigned NumElts = VT.getVectorNumElements();
7998
- if (IndicesVec.getValueType().getVectorNumElements() < NumElts)
7999
- return SDValue();
8000
- else if (IndicesVec.getValueType().getVectorNumElements() > NumElts)
8001
- IndicesVec = extractSubVector(IndicesVec, 0, DAG, SDLoc(IndicesVec),
8002
- NumElts * VT.getScalarSizeInBits());
8003
-
8004
- MVT IndicesVT = EVT(VT).changeVectorElementTypeToInteger().getSimpleVT();
8005
- IndicesVec = DAG.getZExtOrTrunc(IndicesVec, SDLoc(IndicesVec), IndicesVT);
8006
-
8007
8007
if (SrcVec.getValueSizeInBits() > VT.getSizeInBits())
8008
8008
return SDValue();
8009
8009
else if (SrcVec.getValueSizeInBits() < VT.getSizeInBits()) {
0 commit comments