[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Jan 7 22:26:08 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.10 -> 1.11
---
Log message:

Implement the 'store FPIMM, Ptr' -> 'store INTIMM, Ptr' optimization for 
all targets.


---
Diffs of the changes:  (+25 -0)

Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.10 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.11
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.10	Fri Jan  7 16:37:48 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sat Jan  8 00:25:56 2005
@@ -424,6 +424,31 @@
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
     Tmp2 = LegalizeOp(Node->getOperand(2));  // Legalize the pointer.
 
+    // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'
+    if (ConstantFPSDNode *CFP =
+        dyn_cast<ConstantFPSDNode>(Node->getOperand(1))) {
+      if (CFP->getValueType(0) == MVT::f32) {
+        union {
+          unsigned I;
+          float    F;
+        } V;
+        V.F = CFP->getValue();
+        Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1,
+                             DAG.getConstant(V.I, MVT::i32), Tmp2);
+      } else {
+        assert(CFP->getValueType(0) == MVT::f64 && "Unknown FP type!");
+        union {
+          uint64_t I;
+          double   F;
+        } V;
+        V.F = CFP->getValue();
+        Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1,
+                             DAG.getConstant(V.I, MVT::i64), Tmp2);
+      }
+      Op = Result;
+      Node = Op.Val;
+    }
+
     switch (getTypeAction(Node->getOperand(1).getValueType())) {
     case Legal: {
       SDOperand Val = LegalizeOp(Node->getOperand(1));






More information about the llvm-commits mailing list