[PATCH] Fix vselect when getSetCCResultType returns a different type from the operands

Arsenault, Matthew Matthew.Arsenault at amd.com
Tue May 7 13:05:52 PDT 2013


I can do it
________________________________________
From: Nadav Rotem [nrotem at apple.com]
Sent: Tuesday, May 07, 2013 1:04 PM
Cc: Arsenault, Matthew; llvm-commits at cs.uiuc.edu; Michael Liao
Subject: Re: [PATCH] Fix vselect when getSetCCResultType returns a different type from the operands

No need for the braces :)

I will commit this for you.


On May 7, 2013, at 1:02 PM, Matt Arsenault <Matthew.Arsenault at amd.com<mailto:Matthew.Arsenault at amd.com>> wrote:

 Update comment

Hi nadav,

http://llvm-reviews.chandlerc.com/D743

CHANGE SINCE LAST DIFF
 http://llvm-reviews.chandlerc.com/D743?vs=1869&id=1870#toc

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,13 @@
      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.
<D743.4.patch>






More information about the llvm-commits mailing list