diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-02-07 14:22:25 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-02-07 14:22:25 +0000 |
commit | 8c0f62d293059201667c7a3c6d201a18418e4361 (patch) | |
tree | c118c4055648586e6a09c06dd623b3f6070c6021 /llvm/lib | |
parent | b3d0b2d0182d036009f4a0dac7c1d3c52b968f95 (diff) | |
download | bcm5719-llvm-8c0f62d293059201667c7a3c6d201a18418e4361.tar.gz bcm5719-llvm-8c0f62d293059201667c7a3c6d201a18418e4361.zip |
[X86][SSE] Ensure that vector shift-by-immediate inputs are correctly bitcast to the result type
vXi8/vXi64 vector shifts are often shifted as vYi16/vYi32 types but we weren't always remembering to bitcast the input.
Tested with a new assert as we don't currently manipulate these shifts enough for test cases to catch them.
llvm-svn: 294308
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 83b340a1b5c..b3431386252 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -18479,6 +18479,11 @@ static SDValue getTargetVShiftByConstNode(unsigned Opc, const SDLoc &dl, MVT VT, SelectionDAG &DAG) { MVT ElementType = VT.getVectorElementType(); + // Bitcast the source vector to the output type, this is mainly necessary for + // vXi8/vXi64 shifts. + if (VT != SrcOp.getSimpleValueType()) + SrcOp = DAG.getBitcast(VT, SrcOp); + // Fold this packed shift into its first operand if ShiftAmt is 0. if (ShiftAmt == 0) return SrcOp; @@ -18495,9 +18500,8 @@ static SDValue getTargetVShiftByConstNode(unsigned Opc, const SDLoc &dl, MVT VT, && "Unknown target vector shift-by-constant node"); // Fold this packed vector shift into a build vector if SrcOp is a - // vector of Constants or UNDEFs, and SrcOp valuetype is the same as VT. - if (VT == SrcOp.getSimpleValueType() && - ISD::isBuildVectorOfConstantSDNodes(SrcOp.getNode())) { + // vector of Constants or UNDEFs. + if (ISD::isBuildVectorOfConstantSDNodes(SrcOp.getNode())) { SmallVector<SDValue, 8> Elts; unsigned NumElts = SrcOp->getNumOperands(); ConstantSDNode *ND; @@ -30523,8 +30527,10 @@ static SDValue combineVectorShift(SDNode *N, SelectionDAG &DAG, "Unexpected shift opcode"); bool LogicalShift = X86ISD::VSHLI == Opcode || X86ISD::VSRLI == Opcode; EVT VT = N->getValueType(0); + SDValue N0 = N->getOperand(0); unsigned NumBitsPerElt = VT.getScalarSizeInBits(); - assert((NumBitsPerElt % 8) == 0); + assert(VT == N0.getValueType() && (NumBitsPerElt % 8) == 0 && + "Unexpected value type"); // Out of range logical bit shifts are guaranteed to be zero. // Out of range arithmetic bit shifts splat the sign bit. @@ -30536,8 +30542,6 @@ static SDValue combineVectorShift(SDNode *N, SelectionDAG &DAG, ShiftVal = NumBitsPerElt - 1; } - SDValue N0 = N->getOperand(0); - // Shift N0 by zero -> N0. if (!ShiftVal) return N0; |