summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-24 06:45:35 +0000
committerChris Lattner <sabre@nondot.org>2008-01-24 06:45:35 +0000
commit0feb1b0f847c420a64f2ef37a72d1823f8c42305 (patch)
tree72686bad3edb6e78eebeaedc701e15a24f402b96 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent001d781c412374f4613bb34d204d6d5aed3eeff6 (diff)
downloadbcm5719-llvm-0feb1b0f847c420a64f2ef37a72d1823f8c42305.tar.gz
bcm5719-llvm-0feb1b0f847c420a64f2ef37a72d1823f8c42305.zip
fold fp_round(fp_round(x)) -> fp_round(x).
llvm-svn: 46304
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 879a4100e21..5ebda953fbd 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3648,6 +3648,15 @@ SDOperand DAGCombiner::visitFP_ROUND(SDNode *N) {
if (N0.getOpcode() == ISD::FP_EXTEND && VT == N0.getOperand(0).getValueType())
return N0.getOperand(0);
+ // fold (fp_round (fp_round x)) -> (fp_round x)
+ if (N0.getOpcode() == ISD::FP_ROUND) {
+ // This is a value preserving truncation if both round's are.
+ bool IsTrunc = N->getConstantOperandVal(1) == 1 &&
+ N0.Val->getConstantOperandVal(1) == 1;
+ return DAG.getNode(ISD::FP_ROUND, VT, N0.getOperand(0),
+ DAG.getIntPtrConstant(IsTrunc));
+ }
+
// fold (fp_round (copysign X, Y)) -> (copysign (fp_round X), Y)
if (N0.getOpcode() == ISD::FCOPYSIGN && N0.Val->hasOneUse()) {
SDOperand Tmp = DAG.getNode(ISD::FP_ROUND, VT, N0.getOperand(0), N1);
OpenPOWER on IntegriCloud