[llvm-commits] [llvm] r42672 - in /llvm/trunk/lib: CodeGen/SelectionDAG/LegalizeDAG.cpp Target/PowerPC/PPCISelLowering.cpp

Dale Johannesen dalej at apple.com
Fri Oct 5 18:24:12 PDT 2007


Author: johannes
Date: Fri Oct  5 20:24:11 2007
New Revision: 42672

URL: http://llvm.org/viewvc/llvm-project?rev=42672&view=rev
Log:
Next powerpc long double bits.  Comparisons work,
although not well, and shortening FP converts.


Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=42672&r1=42671&r2=42672&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Oct  5 20:24:11 2007
@@ -3314,32 +3314,42 @@
       MVT::ValueType newVT = Op.getValueType();
       MVT::ValueType oldVT = Op.getOperand(0).getValueType();
       if (TLI.getConvertAction(oldVT, newVT) == TargetLowering::Expand) {
-        // The only way we can lower this is to turn it into a STORE,
-        // LOAD pair, targetting a temporary location (a stack slot).
-
-        // NOTE: there is a choice here between constantly creating new stack
-        // slots and always reusing the same one.  We currently always create
-        // new ones, as reuse may inhibit scheduling.
-        MVT::ValueType slotVT = 
-                (Node->getOpcode() == ISD::FP_EXTEND) ? oldVT : newVT;
-        const Type *Ty = MVT::getTypeForValueType(slotVT);
-        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
-        unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
-        MachineFunction &MF = DAG.getMachineFunction();
-        int SSFI =
-          MF.getFrameInfo()->CreateStackObject(TySize, Align);
-        SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
-        if (Node->getOpcode() == ISD::FP_EXTEND) {
-          Result = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0),
-                                     StackSlot, NULL, 0);
-          Result = DAG.getExtLoad(ISD::EXTLOAD, newVT,
-                                     Result, StackSlot, NULL, 0, oldVT);
+        if (Node->getOpcode() == ISD::FP_ROUND && oldVT == MVT::ppcf128) {
+          SDOperand Lo, Hi;
+          ExpandOp(Node->getOperand(0), Lo, Hi);
+          if (newVT == MVT::f64)
+            Result = Hi;
+          else
+            Result = DAG.getNode(ISD::FP_ROUND, newVT, Hi);
+          break;
         } else {
-          Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
-                                     StackSlot, NULL, 0, newVT);
-          Result = DAG.getLoad(newVT, Result, StackSlot, NULL, 0, newVT);
+          // The only other way we can lower this is to turn it into a STORE,
+          // LOAD pair, targetting a temporary location (a stack slot).
+
+          // NOTE: there is a choice here between constantly creating new stack
+          // slots and always reusing the same one.  We currently always create
+          // new ones, as reuse may inhibit scheduling.
+          MVT::ValueType slotVT = 
+                  (Node->getOpcode() == ISD::FP_EXTEND) ? oldVT : newVT;
+          const Type *Ty = MVT::getTypeForValueType(slotVT);
+          uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+          unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
+          MachineFunction &MF = DAG.getMachineFunction();
+          int SSFI =
+            MF.getFrameInfo()->CreateStackObject(TySize, Align);
+          SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
+          if (Node->getOpcode() == ISD::FP_EXTEND) {
+            Result = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0),
+                                       StackSlot, NULL, 0);
+            Result = DAG.getExtLoad(ISD::EXTLOAD, newVT,
+                                       Result, StackSlot, NULL, 0, oldVT);
+          } else {
+            Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
+                                       StackSlot, NULL, 0, newVT);
+            Result = DAG.getLoad(newVT, Result, StackSlot, NULL, 0, newVT);
+          }
+          break;
         }
-        break;
       }
     }
     // FALL THROUGH
@@ -3995,7 +4005,7 @@
 void SelectionDAGLegalize::LegalizeSetCCOperands(SDOperand &LHS,
                                                  SDOperand &RHS,
                                                  SDOperand &CC) {
-  SDOperand Tmp1, Tmp2, Result;    
+  SDOperand Tmp1, Tmp2, Tmp3, Result;    
   
   switch (getTypeAction(LHS.getValueType())) {
   case Legal:
@@ -4126,8 +4136,27 @@
 
     SDOperand LHSLo, LHSHi, RHSLo, RHSHi;
     ExpandOp(LHS, LHSLo, LHSHi);
-    ExpandOp(RHS, RHSLo, RHSHi);    
-    switch (cast<CondCodeSDNode>(CC)->get()) {
+    ExpandOp(RHS, RHSLo, RHSHi);
+    ISD::CondCode CCCode = cast<CondCodeSDNode>(CC)->get();
+
+    if (VT==MVT::ppcf128) {
+      // FIXME:  This generated code sucks.  We want to generate
+      //         FCMP crN, hi1, hi2
+      //         BNE crN, L:
+      //         FCMP crN, lo1, lo2
+      // The following can be improved, but not that much.
+      Tmp1 = DAG.getSetCC(TLI.getSetCCResultTy(), LHSHi, RHSHi, ISD::SETEQ);
+      Tmp2 = DAG.getSetCC(TLI.getSetCCResultTy(), LHSLo, RHSLo, CCCode);
+      Tmp3 = DAG.getNode(ISD::AND, Tmp1.getValueType(), Tmp1, Tmp2);
+      Tmp1 = DAG.getSetCC(TLI.getSetCCResultTy(), LHSHi, RHSHi, ISD::SETNE);
+      Tmp2 = DAG.getSetCC(TLI.getSetCCResultTy(), LHSHi, RHSHi, CCCode);
+      Tmp1 = DAG.getNode(ISD::AND, Tmp1.getValueType(), Tmp1, Tmp2);
+      Tmp1 = DAG.getNode(ISD::OR, Tmp1.getValueType(), Tmp1, Tmp3);
+      Tmp2 = SDOperand();
+      break;
+    }
+
+    switch (CCCode) {
     case ISD::SETEQ:
     case ISD::SETNE:
       if (RHSLo == RHSHi)
@@ -4159,7 +4188,6 @@
 
       // FIXME: This generated code sucks.
       ISD::CondCode LowCC;
-      ISD::CondCode CCCode = cast<CondCodeSDNode>(CC)->get();
       switch (CCCode) {
       default: assert(0 && "Unknown integer setcc!");
       case ISD::SETLT:

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=42672&r1=42671&r2=42672&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Oct  5 20:24:11 2007
@@ -73,6 +73,10 @@
   setOperationAction(ISD::ConstantFP, MVT::f64, Expand);
   setOperationAction(ISD::ConstantFP, MVT::f32, Expand);
 
+  // Shortening conversions involving ppcf128 get expanded (2 regs -> 1 reg)
+  setConvertAction(MVT::ppcf128, MVT::f64, Expand);
+  setConvertAction(MVT::ppcf128, MVT::f32, Expand);
+
   // PowerPC has no intrinsics for these particular operations
   setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
   setOperationAction(ISD::MEMSET, MVT::Other, Expand);





More information about the llvm-commits mailing list