Teach LegalizeTypes how to expand the operands of
authorDuncan Sands <baldrick@free.fr>
Sat, 16 Feb 2008 10:29:26 +0000 (10:29 +0000)
committerDuncan Sands <baldrick@free.fr>
Sat, 16 Feb 2008 10:29:26 +0000 (10:29 +0000)
br_cc.  This fixes 5 "make check" failures.

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

lib/CodeGen/SelectionDAG/LegalizeTypes.h
lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp

index 47985c7e8aa366f705cf3cc49a18d5c484258419..acae44b2ac1ec60329f06122d292185e588442ff 100644 (file)
@@ -238,14 +238,15 @@ private:
 
   // Operand Expansion.
   bool ExpandOperand(SDNode *N, unsigned OperandNo);
-  SDOperand ExpandOperand_TRUNCATE(SDNode *N);
   SDOperand ExpandOperand_BIT_CONVERT(SDNode *N);
-  SDOperand ExpandOperand_UINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
-  SDOperand ExpandOperand_SINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
+  SDOperand ExpandOperand_BR_CC(SDNode *N);
   SDOperand ExpandOperand_EXTRACT_ELEMENT(SDNode *N);
   SDOperand ExpandOperand_SETCC(SDNode *N);
+  SDOperand ExpandOperand_SINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
   SDOperand ExpandOperand_STORE(StoreSDNode *N, unsigned OpNo);
-  
+  SDOperand ExpandOperand_TRUNCATE(SDNode *N);
+  SDOperand ExpandOperand_UINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
+
   void ExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
                            ISD::CondCode &CCCode);
   
index 136ae6868653d92a6ca30030ed1dee09774500f6..b440e7ab9360deb36bfc93dba7eca35a6a63c10e 100644 (file)
@@ -850,6 +850,8 @@ bool DAGTypeLegalizer::ExpandOperand(SDNode *N, unsigned OpNo) {
       Res = ExpandOperand_UINT_TO_FP(N->getOperand(0), N->getValueType(0)); 
       break;
     case ISD::EXTRACT_ELEMENT: Res = ExpandOperand_EXTRACT_ELEMENT(N); break;
+
+    case ISD::BR_CC:           Res = ExpandOperand_BR_CC(N); break;
     case ISD::SETCC:           Res = ExpandOperand_SETCC(N); break;
 
     case ISD::STORE:
@@ -976,6 +978,24 @@ SDOperand DAGTypeLegalizer::ExpandOperand_EXTRACT_ELEMENT(SDNode *N) {
   return cast<ConstantSDNode>(N->getOperand(1))->getValue() ? Hi : Lo;
 }
 
+SDOperand DAGTypeLegalizer::ExpandOperand_BR_CC(SDNode *N) {
+  SDOperand NewLHS = N->getOperand(2), NewRHS = N->getOperand(3);
+  ISD::CondCode CCCode = cast<CondCodeSDNode>(N->getOperand(1))->get();
+  ExpandSetCCOperands(NewLHS, NewRHS, CCCode);
+
+  // If ExpandSetCCOperands returned a scalar, we need to compare the result
+  // against zero to select between true and false values.
+  if (NewRHS.Val == 0) {
+    NewRHS = DAG.getConstant(0, NewLHS.getValueType());
+    CCCode = ISD::SETNE;
+  }
+
+  // Update N to have the operands specified.
+  return DAG.UpdateNodeOperands(SDOperand(N, 0), N->getOperand(0),
+                                DAG.getCondCode(CCCode), NewLHS, NewRHS,
+                                N->getOperand(4));
+}
+
 SDOperand DAGTypeLegalizer::ExpandOperand_SETCC(SDNode *N) {
   SDOperand NewLHS = N->getOperand(0), NewRHS = N->getOperand(1);
   ISD::CondCode CCCode = cast<CondCodeSDNode>(N->getOperand(2))->get();