[PATCH] Fix vselect when getSetCCResultType returns a different type from the operands
Michael Liao
michael.liao at intel.com
Fri May 3 20:54:36 PDT 2013
test case?
- michael
On Fri, 2013-05-03 at 20:42 -0700, Matt Arsenault wrote:
> Hi nadav,
>
> http://llvm-reviews.chandlerc.com/D743
>
> Files:
> lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
>
> Index: lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
> +++ lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
> @@ -652,13 +652,14 @@
> SDValue VectorLegalizer::ExpandVSELECT(SDValue Op) {
> // Implement VSELECT in terms of XOR, AND, OR
> // on platforms which do not support blend natively.
> - EVT VT = Op.getOperand(0).getValueType();
> DebugLoc DL = Op.getDebugLoc();
>
> SDValue Mask = Op.getOperand(0);
> SDValue Op1 = Op.getOperand(1);
> SDValue Op2 = Op.getOperand(2);
>
> + EVT VT = Mask.getValueType();
> +
> // If we can't even use the basic vector operations of
> // AND,OR,XOR, we will have to scalarize the op.
> // Notice that the operation may be 'promoted' which means that it is
> @@ -673,8 +674,22 @@
> TargetLowering::ZeroOrNegativeOneBooleanContent)
> return DAG.UnrollVectorOp(Op.getNode());
>
> - assert(VT.getSizeInBits() == Op1.getValueType().getSizeInBits()
> - && "Invalid mask size");
> + // If the mask and the type do not match and Select is legal,
> + // go ahead and unroll the vector op.
> + // This occurs when getSetCCResultType returns something that
> + // is different than the operand types. For example,
> + // v4i8 = select v4i32, v4i8, v4i8.
> + if (Op1.getValueType() != VT &&
> + TLI.getTypeAction(*DAG.getContext(), VT.getScalarType())
> + == TargetLowering::TypeLegal &&
> + TLI.getOperationAction(ISD::SELECT, VT.getScalarType())
> + == TargetLowering::Legal) {
> + return DAG.UnrollVectorOp(Op.getNode());
> + }
> +
> + assert(VT.getSizeInBits() == Op.getOperand(1).getValueType().getSizeInBits()
> + && "Invalid mask size and ISD::SELECT is not Legal!");
> +
> // Bitcast the operands to be the same type as the mask.
> // This is needed when we select between FP types because
> // the mask is a vector of integers.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list