implement promotion of select and select_cc, allowing MallocBench/gs to
authorChris Lattner <sabre@nondot.org>
Tue, 16 Oct 2007 03:00:22 +0000 (03:00 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 16 Oct 2007 03:00:22 +0000 (03:00 +0000)
work with type promotion on x86.

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

lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp

index d815111048d5d8cbc8a2e53d5d9136835d5ca9f3..8752698098a37a8a132519d7a5c5569b1b8a0302 100644 (file)
@@ -130,6 +130,8 @@ private:
   SDOperand PromoteResult_SETCC(SDNode *N);
   SDOperand PromoteResult_LOAD(LoadSDNode *N);
   SDOperand PromoteResult_SimpleIntBinOp(SDNode *N);
+  SDOperand PromoteResult_SELECT   (SDNode *N);
+  SDOperand PromoteResult_SELECT_CC(SDNode *N);
   
   // Result Expansion.
   void ExpandResult(SDNode *N, unsigned ResNo);
@@ -450,6 +452,10 @@ void DAGTypeLegalizer::PromoteResult(SDNode *N, unsigned ResNo) {
   case ISD::ADD:
   case ISD::SUB:
   case ISD::MUL:      Result = PromoteResult_SimpleIntBinOp(N); break;
+    
+  case ISD::SELECT:    Result = PromoteResult_SELECT(N); break;
+  case ISD::SELECT_CC: Result = PromoteResult_SELECT_CC(N); break;
+
   }      
   
   // If Result is null, the sub-method took care of registering the result.
@@ -552,6 +558,19 @@ SDOperand DAGTypeLegalizer::PromoteResult_SimpleIntBinOp(SDNode *N) {
   return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, RHS);
 }
 
+SDOperand DAGTypeLegalizer::PromoteResult_SELECT(SDNode *N) {
+  SDOperand LHS = GetPromotedOp(N->getOperand(1));
+  SDOperand RHS = GetPromotedOp(N->getOperand(2));
+  return DAG.getNode(ISD::SELECT, LHS.getValueType(), N->getOperand(0),LHS,RHS);
+}
+
+SDOperand DAGTypeLegalizer::PromoteResult_SELECT_CC(SDNode *N) {
+  SDOperand LHS = GetPromotedOp(N->getOperand(2));
+  SDOperand RHS = GetPromotedOp(N->getOperand(3));
+  return DAG.getNode(ISD::SELECT_CC, LHS.getValueType(), N->getOperand(0),
+                     N->getOperand(1), LHS, RHS, N->getOperand(4));
+}
+
 //===----------------------------------------------------------------------===//
 //  Result Expansion
 //===----------------------------------------------------------------------===//