diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-07 21:56:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-07 21:56:24 +0000 |
commit | fd8c39b77331fbb6f994665b45eba1b2cc6ced6d (patch) | |
tree | cfcd12c056ebf0922053a35acd1ef6e402933f59 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 03c0cf822e9a57109d1b4e6a2705d68852c93e1d (diff) |
Simplify: truncate ({zero|sign}_extend (X))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3fdc7fe995..25ec8ff052 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -428,6 +428,15 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, if (Operand.getValueType() == VT) return Operand; // noop truncate if (OpOpcode == ISD::TRUNCATE) return getNode(ISD::TRUNCATE, VT, Operand.Val->getOperand(0)); + else if (OpOpcode == ISD::ZERO_EXTEND || OpOpcode == ISD::SIGN_EXTEND) { + // If the source is smaller than the dest, we still need an extend. + if (Operand.Val->getOperand(0).getValueType() < VT) + return getNode(OpOpcode, VT, Operand.Val->getOperand(0)); + else if (Operand.Val->getOperand(0).getValueType() > VT) + return getNode(ISD::TRUNCATE, VT, Operand.Val->getOperand(0)); + else + return Operand.Val->getOperand(0); + } break; } |