Delete dead loads in the dag. This allows us to compile
authorChris Lattner <sabre@nondot.org>
Fri, 31 Mar 2006 18:06:18 +0000 (18:06 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Mar 2006 18:06:18 +0000 (18:06 +0000)
vector.ll:test_extract_elt2 into:

_test_extract_elt2:
        lfd f1, 32(r3)
        blr

instead of:

_test_extract_elt2:
        lfd f0, 56(r3)
        lfd f0, 48(r3)
        lfd f0, 40(r3)
        lfd f1, 32(r3)
        lfd f0, 24(r3)
        lfd f0, 16(r3)
        lfd f0, 8(r3)
        lfd f0, 0(r3)
        blr

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27296 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index a559d3e469e2b7ba4cd36ad93d4a7157706df9ef..4d1e39359ba5ebffba2c3eae802bf324ec044911 100644 (file)
@@ -2261,6 +2261,11 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) {
   SDOperand Chain    = N->getOperand(0);
   SDOperand Ptr      = N->getOperand(1);
   SDOperand SrcValue = N->getOperand(2);
+
+  // If there are no uses of the loaded value, change uses of the chain value
+  // into uses of the chain input (i.e. delete the dead load).
+  if (N->hasNUsesOfValue(0, 0))
+    return CombineTo(N, DAG.getNode(ISD::UNDEF, N->getValueType(0)), Chain);
   
   // If this load is directly stored, replace the load value with the stored
   // value.