summaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-05-07 20:24:18 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-05-07 20:24:18 +0000
commit798925bac73b9320e7b32001478921910ac781d2 (patch)
tree4558a38abbe8895b7e8ad8491f7f98ea2949c73b /lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
parentacccd2edc8d4c078aa03c4dd43ef815087176ef9 (diff)
downloadllvm-798925bac73b9320e7b32001478921910ac781d2.tar.gz
llvm-798925bac73b9320e7b32001478921910ac781d2.tar.bz2
llvm-798925bac73b9320e7b32001478921910ac781d2.tar.xz
Fix vselect when getSetCCResultType returns a different type from the operands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
index c6e066e270..33888b3422 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -652,13 +652,14 @@ SDValue VectorLegalizer::ExpandSEXTINREG(SDValue Op) {
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,12 @@ SDValue VectorLegalizer::ExpandVSELECT(SDValue Op) {
TargetLowering::ZeroOrNegativeOneBooleanContent)
return DAG.UnrollVectorOp(Op.getNode());
- assert(VT.getSizeInBits() == Op1.getValueType().getSizeInBits()
- && "Invalid mask size");
+ // If the mask and the type are different sizes, unroll the vector op. This
+ // can occur when getSetCCResultType returns something that is different in
+ // size from the operand types. For example, v4i8 = select v4i32, v4i8, v4i8.
+ if (VT.getSizeInBits() != Op1.getValueType().getSizeInBits())
+ return DAG.UnrollVectorOp(Op.getNode());
+
// 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.