Don't use getSetCCResultType for creating a vselect
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 10 Sep 2013 00:41:56 +0000 (00:41 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 10 Sep 2013 00:41:56 +0000 (00:41 +0000)
The vselect mask isn't a setcc.

This breaks in the case when the result of getSetCCResultType
is larger than the vector operands

e.g. %tmp = select i1 %cmp <2 x i8> %a, <2 x i8> %b
when getSetCCResultType returns <2 x i32>, the assertion
that the (MaskTy.getSizeInBits() == Op1.getValueType().getSizeInBits())
is hit.

No test since I don't think I can hit this with any of the current
targets. The R600/SI implementation would break, since it returns a
vector of i1 for this, but it doesn't reach ExpandSELECT for other
reasons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190376 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

index 6e5fdca361e4738a57cf278235de0b3d92ec8dc1..fcb48b9b1be7c161ed0decafd99007cab1ca5c69 100644 (file)
@@ -599,8 +599,7 @@ SDValue VectorLegalizer::ExpandSELECT(SDValue Op) {
     return DAG.UnrollVectorOp(Op.getNode());
 
   // Generate a mask operand.
-  EVT MaskTy = TLI.getSetCCResultType(*DAG.getContext(), VT);
-  assert(MaskTy.isVector() && "Invalid CC type");
+  EVT MaskTy = VT.changeVectorElementTypeToInteger();
   assert(MaskTy.getSizeInBits() == Op1.getValueType().getSizeInBits()
          && "Invalid mask size");