Eliminate unneeded extensions.
authorChris Lattner <sabre@nondot.org>
Sun, 16 Jan 2005 00:17:20 +0000 (00:17 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 16 Jan 2005 00:17:20 +0000 (00:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19577 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 89c53e8c1ba6a4c9444175481a68c23437cefe91..d3d44a82e080316371842a65965d35f02ae61473 100644 (file)
@@ -855,6 +855,15 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
            "Cannot *_EXTEND_INREG FP types");
     if (EVT == VT) return N1;  // Not actually extending
     assert(EVT < VT && "Not extending!");
+
+    // If we are sign extending an extension, use the original source.
+    if (N1.getOpcode() == ISD::ZERO_EXTEND_INREG ||
+        N1.getOpcode() == ISD::SIGN_EXTEND_INREG) {
+      if (N1.getOpcode() == Opcode &&
+          cast<MVTSDNode>(N1)->getExtraValueType() <= EVT)
+        return N1;
+    }
+
     break;
   }