[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 29 17:30:54 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelDAGToDAG.cpp updated: 1.54 -> 1.55
---
Log message:

emit FMR instructions to convert f64<->f32 instructions, so things like
STOREs, know the right type to store.


---
Diffs of the changes:  (+15 -8)

 PPC32ISelDAGToDAG.cpp |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.54 llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.55
--- llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.54	Mon Aug 29 18:49:25 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp	Mon Aug 29 19:30:43 2005
@@ -1113,14 +1113,13 @@
     CurDAG->SelectNodeTo(N, PPC::FABS, N->getValueType(0), 
                          Select(N->getOperand(0)));
     break;
-  case ISD::FP_EXTEND: {
+  case ISD::FP_EXTEND:
     assert(MVT::f64 == N->getValueType(0) && 
            MVT::f32 == N->getOperand(0).getValueType() && "Illegal FP_EXTEND");
-    std::vector<SDOperand> Tmp;
-    Tmp.push_back(Select(N->getOperand(0)));
-    CurDAG->ReplaceAllUsesWith(N, Tmp);  // Just use the operand as the result.
-    return Tmp[0];
-  }
+    // We need to emit an FMR to make sure that the result has the right value
+    // type.
+    CurDAG->SelectNodeTo(N, PPC::FMR, MVT::f64, Select(N->getOperand(0)));
+    break;
   case ISD::FP_ROUND:
     assert(MVT::f32 == N->getValueType(0) && 
            MVT::f64 == N->getOperand(0).getValueType() && "Illegal FP_ROUND");
@@ -1560,7 +1559,12 @@
     case MVT::f32:
     case MVT::f64:
       Chain = CurDAG->getCopyFromReg(Chain, PPC::F1, MVT::f64).getValue(1);
-      CallResults.push_back(Chain.getValue(0));
+      if (N->getValueType(0) == MVT::f64)
+        CallResults.push_back(Chain.getValue(0));
+      else
+        // Insert an FMR to convert the result to f32 from f64.
+        CallResults.push_back(CurDAG->getTargetNode(PPC::FMR, MVT::f32,
+                                                    Chain.getValue(0)));
       break;
     }
     
@@ -1575,8 +1579,11 @@
       SDOperand Val = Select(N->getOperand(1));
       switch (N->getOperand(1).getValueType()) {
       default: assert(0 && "Unknown return type!");
-      case MVT::f64:
       case MVT::f32:
+        // Insert a copy to get the type right.
+        Val = CurDAG->getTargetNode(PPC::FMR, MVT::f64, Val);
+        // FALL THROUGH
+      case MVT::f64:
         Chain = CurDAG->getCopyToReg(Chain, PPC::F1, Val);
         break;
       case MVT::i32:






More information about the llvm-commits mailing list