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

Chris Lattner lattner at cs.uiuc.edu
Thu Dec 22 21:44:53 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.72 -> 1.73
---
Log message:

fold (conv (load x)) -> (load (conv*)x).

This allows us to compile this:
void foo(double);
void bar(double *X) { foo(*X); }

To this:

bar:
        save -96, %o6, %o6
        ld [%i0+4], %o1
        ld [%i0], %o0
        call foo
        nop
        restore %g0, %g0, %g0
        retl
        nop

instead of this:

bar:
        save -104, %o6, %o6
        ldd [%i0], %f0
        std %f0, [%i6+-8]
        ld [%i6+-4], %o1
        ld [%i6+-8], %o0
        call foo
        nop
        restore %g0, %g0, %g0
        retl
        nop

on SparcV8.



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

 DAGCombiner.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.72 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.73
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.72	Thu Dec 22 23:37:50 2005
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Thu Dec 22 23:44:41 2005
@@ -1760,6 +1760,16 @@
   if (N0.getOpcode() == ISD::BIT_CONVERT)  // conv(conv(x,t1),t2) -> conv(x,t2)
     return DAG.getNode(ISD::BIT_CONVERT, VT, N0.getOperand(0));
   
+  // fold (conv (load x)) -> (load (conv*)x)
+  if (N0.getOpcode() == ISD::LOAD && N0.hasOneUse()) {
+    SDOperand Load = DAG.getLoad(VT, N0.getOperand(0), N0.getOperand(1),
+                                 N0.getOperand(2));
+    WorkList.push_back(N);
+    CombineTo(N0.Val, DAG.getNode(ISD::BIT_CONVERT, N0.getValueType(), Load),
+              Load.getValue(1));
+    return Load;
+  }
+  
   return SDOperand();
 }
 






More information about the llvm-commits mailing list