[llvm] r327140 - [X86][SSE] createVariablePermute - move index vector canonicalization to top of function. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 9 07:48:56 PST 2018
Author: rksimon
Date: Fri Mar 9 07:48:56 2018
New Revision: 327140
URL: http://llvm.org/viewvc/llvm-project?rev=327140&view=rev
Log:
[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.
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=327140&r1=327139&r2=327140&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Mar 9 07:48:56 2018
@@ -7914,9 +7914,19 @@ static SDValue materializeVectorConstant
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, SD
(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()) {
More information about the llvm-commits
mailing list