diff options
| author | Dan Gohman <gohman@apple.com> | 2009-01-23 19:10:37 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-01-23 19:10:37 +0000 |
| commit | 1275e28dede2fda98c46c1c85892f893af451d01 (patch) | |
| tree | bcc754c8eded75d07ecec76279f1613138e18f07 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
| parent | 5da47ad57b8e899736015c01823cbb1a10518c30 (diff) | |
| download | bcm5719-llvm-1275e28dede2fda98c46c1c85892f893af451d01.tar.gz bcm5719-llvm-1275e28dede2fda98c46c1c85892f893af451d01.zip | |
Fold x-0 to x in unsafe-fp-math mode. This comes up in the
testcase from PR3376, and in fact is sufficient to completely
avoid the problem in that testcase.
There's an underlying problem though; TLI.isOperationLegal
considers Custom to be Legal, which might be ok in some
cases, but that's what DAGCombiner is using in many places
to test if something is legal when LegalOperations is true.
When DAGCombiner is running after legalize, this isn't
sufficient. I'll address this in a separate commit.
llvm-svn: 62860
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 7e8e46fba50..e4b24f1aaff 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3853,6 +3853,9 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) { // fold (fsub c1, c2) -> c1-c2 if (N0CFP && N1CFP && VT != MVT::ppcf128) return DAG.getNode(ISD::FSUB, VT, N0, N1); + // fold (A-0) -> A + if (UnsafeFPMath && N1CFP && N1CFP->getValueAPF().isZero()) + return N0; // fold (0-B) -> -B if (UnsafeFPMath && N0CFP && N0CFP->getValueAPF().isZero()) { if (isNegatibleForFree(N1, LegalOperations)) |

