[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 7 13:57:09 PST 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAG.cpp updated: 1.9 -> 1.10
---
Log message:
Simplify: truncate ({zero|sign}_extend (X))
---
Diffs of the changes: (+9 -0)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.9 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.10
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.9 Fri Jan 7 15:09:16 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jan 7 15:56:24 2005
@@ -428,6 +428,15 @@
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;
}
More information about the llvm-commits
mailing list