diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-24 06:45:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-24 06:45:35 +0000 |
commit | 0aa5e6f3fbde81c0bf0310ab0582420f0eeb7155 (patch) | |
tree | 6d443b475071ce1dca5d5fd9dbcc3111569c256e /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 7323999b3192293eb5985e00d97de2a4be20a039 (diff) |
fold fp_round(fp_round(x)) -> fp_round(x).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46304 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 879a4100e2..5ebda953fb 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/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); |