summaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-01 16:56:08 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-01 16:56:08 +0000
commit19fe54013d6fee3a0db99b3e20f25a706002fb16 (patch)
treec7cb5d93af1f6099cec88dc9bb98ff85b1058671 /gcc/tree.c
parent0425437e0f2629e9b1733a8b116b2fca4d0c8154 (diff)
downloadgcc-19fe54013d6fee3a0db99b3e20f25a706002fb16.tar.gz
* tree.c (real_minus_onep): New function to test for -1.0.
* fold-const.c (fold) [MULT_EXPR]: Optimize -1.0*x into -x. * gcc.dg/fnegate-1.c: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54149 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 15f156aea0a..04ae6ce5348 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -892,6 +892,22 @@ real_twop (expr)
&& real_zerop (TREE_IMAGPART (expr))));
}
+/* Return 1 if EXPR is the real constant minus one. */
+
+int
+real_minus_onep (expr)
+ tree expr;
+{
+ STRIP_NOPS (expr);
+
+ return ((TREE_CODE (expr) == REAL_CST
+ && ! TREE_CONSTANT_OVERFLOW (expr)
+ && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconstm1))
+ || (TREE_CODE (expr) == COMPLEX_CST
+ && real_minus_onep (TREE_REALPART (expr))
+ && real_zerop (TREE_IMAGPART (expr))));
+}
+
/* Nonzero if EXP is a constant or a cast of a constant. */
int