summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-07 21:56:24 +0000
committerChris Lattner <sabre@nondot.org>2005-01-07 21:56:24 +0000
commit4d5ba992839a0ff67c0a9dc67337fa212973ccf4 (patch)
tree4b7a12d28c55f5a798f87d39b5cdc3ee917bcff1 /llvm/lib/CodeGen/SelectionDAG
parent32f20bfa93628de3732dd8814e59216caa5c4c54 (diff)
downloadbcm5719-llvm-4d5ba992839a0ff67c0a9dc67337fa212973ccf4.tar.gz
bcm5719-llvm-4d5ba992839a0ff67c0a9dc67337fa212973ccf4.zip
Simplify: truncate ({zero|sign}_extend (X))
llvm-svn: 19353
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3fdc7fe995f..25ec8ff0529 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud