Fix PR3011: LegalizeTypes support for scalarizing
authorDuncan Sands <baldrick@free.fr>
Tue, 4 Nov 2008 17:31:08 +0000 (17:31 +0000)
committerDuncan Sands <baldrick@free.fr>
Tue, 4 Nov 2008 17:31:08 +0000 (17:31 +0000)
SELECT_CC.

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

lib/CodeGen/SelectionDAG/LegalizeTypes.h
lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
test/CodeGen/PowerPC/select-cc.ll [new file with mode: 0644]

index 530a115b9af4535b33ef11ad3ce25409834619a1..7f33b879d389ddcba38c6011c8efdb815594ba61 100644 (file)
@@ -452,6 +452,7 @@ private:
   SDValue ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N);
   SDValue ScalarizeVecRes_LOAD(LoadSDNode *N);
   SDValue ScalarizeVecRes_SELECT(SDNode *N);
+  SDValue ScalarizeVecRes_SELECT_CC(SDNode *N);
   SDValue ScalarizeVecRes_UNDEF(SDNode *N);
   SDValue ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N);
   SDValue ScalarizeVecRes_VSETCC(SDNode *N);
index 0b9645db271cb372c618ae4d0d33ac38c7b20933..cfb85fd984935c56d3ef86e8f707c08ad9e89619 100644 (file)
@@ -48,6 +48,7 @@ void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
   case ISD::INSERT_VECTOR_ELT: R = ScalarizeVecRes_INSERT_VECTOR_ELT(N); break;
   case ISD::LOAD:           R = ScalarizeVecRes_LOAD(cast<LoadSDNode>(N));break;
   case ISD::SELECT:         R = ScalarizeVecRes_SELECT(N); break;
+  case ISD::SELECT_CC:      R = ScalarizeVecRes_SELECT_CC(N); break;
   case ISD::UNDEF:          R = ScalarizeVecRes_UNDEF(N); break;
   case ISD::VECTOR_SHUFFLE: R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break;
   case ISD::VSETCC:         R = ScalarizeVecRes_VSETCC(N); break;
@@ -162,6 +163,14 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT(SDNode *N) {
                      GetScalarizedVector(N->getOperand(2)));
 }
 
+SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT_CC(SDNode *N) {
+  SDValue LHS = GetScalarizedVector(N->getOperand(2));
+  return DAG.getNode(ISD::SELECT_CC, LHS.getValueType(),
+                     N->getOperand(0), N->getOperand(1),
+                     LHS, GetScalarizedVector(N->getOperand(3)),
+                     N->getOperand(4));
+}
+
 SDValue DAGTypeLegalizer::ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N) {
   // Figure out if the scalar is the LHS or RHS and return it.
   SDValue Arg = N->getOperand(2).getOperand(0);
diff --git a/test/CodeGen/PowerPC/select-cc.ll b/test/CodeGen/PowerPC/select-cc.ll
new file mode 100644 (file)
index 0000000..f9464c4
--- /dev/null
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | llc -march=ppc32
+; PR3011
+
+define <2 x double> @vector_select(<2 x double> %x, <2 x double> %y) nounwind  {
+       %x.lo = extractelement <2 x double> %x, i32 0           ; <double> [#uses=1]
+       %x.lo.ge = fcmp oge double %x.lo, 0.000000e+00          ; <i1> [#uses=1]
+       %a.d = select i1 %x.lo.ge, <2 x double> %y, <2 x double> %x             ; <<2 x double>> [#uses=1]
+       ret <2 x double> %a.d
+}