[llvm-commits] [llvm] r40965 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Dale Johannesen dalej at apple.com
Thu Aug 9 10:27:49 PDT 2007


Author: johannes
Date: Thu Aug  9 12:27:48 2007
New Revision: 40965

URL: http://llvm.org/viewvc/llvm-project?rev=40965&view=rev
Log:
Update per review comments.

Modified:
    llvm/trunk/include/llvm/Target/TargetLowering.h
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=40965&r1=40964&r2=40965&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu Aug  9 12:27:48 2007
@@ -333,8 +333,8 @@
   /// for it.
   LegalizeAction
   getConvertAction(MVT::ValueType FromVT, MVT::ValueType ToVT) const {
-    if (MVT::isExtendedVT(ToVT) || MVT::isExtendedVT(FromVT))
-      return Expand;
+    assert(FromVT < MVT::LAST_VALUETYPE && ToVT < 32 && 
+           "Table isn't big enough!");
     return (LegalizeAction)((ConvertActions[FromVT] >> (2*ToVT)) & 3);
   }
 

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

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Aug  9 12:27:48 2007
@@ -3194,51 +3194,36 @@
     }
     break;
 
-  case ISD::FP_EXTEND: {
-      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,
-        // EXTLOAD 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.
-        const Type *Ty = MVT::getTypeForValueType(oldVT);
-        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());
-        Result = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0),
-                                   StackSlot, NULL, 0);
-        Result = DAG.getExtLoad(ISD::EXTLOAD, newVT,
-                                   Result, StackSlot, NULL, 0, oldVT);
-        break;
-      }
-    }
-    // FALL THROUGH (to ANY_EXTEND case)
+  case ISD::FP_EXTEND: 
   case ISD::FP_ROUND: {
       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 TRUNCSTORE,
+        // 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.
-        const Type *Ty = MVT::getTypeForValueType(newVT);
+        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());
-        Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
-                                   StackSlot, NULL, 0, newVT);
-        Result = DAG.getLoad(newVT, Result, StackSlot, NULL, 0, newVT);
+        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;
       }
     }





More information about the llvm-commits mailing list