Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Commit 28bfb18

Browse files
author
Simon Pilgrim
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327140 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent cd24f9e commit 28bfb18

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7914,9 +7914,19 @@ static SDValue materializeVectorConstant(SDValue Op, SelectionDAG &DAG,
79147914
SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
79157915
SDLoc &DL, SelectionDAG &DAG,
79167916
const X86Subtarget &Subtarget) {
7917-
unsigned Opcode = 0;
79187917
MVT ShuffleVT = VT;
7918+
EVT IndicesVT = EVT(VT).changeVectorElementTypeToInteger();
7919+
unsigned NumElts = VT.getVectorNumElements();
79197920

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;
79207930
switch (VT.SimpleTy) {
79217931
default:
79227932
break;
@@ -7994,16 +8004,6 @@ SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
79948004
(VT.getScalarSizeInBits() % ShuffleVT.getScalarSizeInBits()) == 0 &&
79958005
"Illegal variable permute shuffle type");
79968006

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-
80078007
if (SrcVec.getValueSizeInBits() > VT.getSizeInBits())
80088008
return SDValue();
80098009
else if (SrcVec.getValueSizeInBits() < VT.getSizeInBits()) {

0 commit comments

Comments
 (0)