aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2012-05-07 20:51:25 +0000
committerOwen Anderson <resistor@mac.com>2012-05-07 20:51:25 +0000
commit713e953118175d693a3fddbf6a61dc73aa69ad87 (patch)
treeef945f02d87468cf3a09338e3fda0a36da75128f /lib/CodeGen
parent423f19f2dadee9325766008b63c1faf3c644043b (diff)
downloadexternal_llvm-713e953118175d693a3fddbf6a61dc73aa69ad87.tar.gz
external_llvm-713e953118175d693a3fddbf6a61dc73aa69ad87.tar.bz2
external_llvm-713e953118175d693a3fddbf6a61dc73aa69ad87.zip
Teach DAG combine to fold x-x to 0.0 when unsafe FP math is enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156324 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index c2b7f6c513..753ba937c0 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5670,9 +5670,13 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
GetNegatedExpression(N1, DAG, LegalOperations));
// If 'unsafe math' is enabled, fold
+ // (fsub x, x) -> 0.0 &
// (fsub x, (fadd x, y)) -> (fneg y) &
// (fsub x, (fadd y, x)) -> (fneg y)
if (DAG.getTarget().Options.UnsafeFPMath) {
+ if (N0 == N1)
+ return DAG.getConstantFP(0.0f, VT);
+
if (N1.getOpcode() == ISD::FADD) {
SDValue N10 = N1->getOperand(0);
SDValue N11 = N1->getOperand(1);