From 3cbc0a3be5d6ca80a59d95548ad1a7ba1a58b5ef Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 9 Mar 2018 15:48:56 +0000 Subject: [PATCH] [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 --- lib/Target/X86/X86ISelLowering.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 0d771964f03..ade69220c4c 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -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()) { -- 2.11.0