From 4b69983dc66a8d9910642c9d968fc44aa6fd37f3 Mon Sep 17 00:00:00 2001 From: sayle Date: Tue, 26 Aug 2003 21:44:46 +0000 Subject: [PATCH] PR middle-end/12002 * tree.h (SCALAR_FLOAT_TYPE_P, COMPLEX_FLOAT_TYPE_P): New macros. (FLOAT_TYPE_P): Define in terms of these two new macros. * fold-const.c (fold ): Don't convert x+x into x*2.0 for complex floating point types. * g77.f-torture/compile/12002.f: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70821 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/fold-const.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g77.f-torture/compile/12002.f | 5 +++++ gcc/tree.h | 14 +++++++++++--- 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g77.f-torture/compile/12002.f diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 746dec5..6830aee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2003-08-26 Roger Sayle + + PR middle-end/12002 + * tree.h (SCALAR_FLOAT_TYPE_P, COMPLEX_FLOAT_TYPE_P): New macros. + (FLOAT_TYPE_P): Define in terms of these two new macros. + * fold-const.c (fold ): Don't convert x+x into x*2.0 + for complex floating point types. + 2003-08-26 Ulrich Weigand * config/s390/s390.c (emit_prologue): Don't check literal pool size. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index efa2db9..68a92a2 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5713,7 +5713,8 @@ fold (tree expr) return non_lvalue (convert (type, arg1)); /* Convert x+x into x*2.0. */ - if (operand_equal_p (arg0, arg1, 0)) + if (operand_equal_p (arg0, arg1, 0) + && SCALAR_FLOAT_TYPE_P (type)) return fold (build (MULT_EXPR, type, arg0, build_real (type, dconst2))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ba803a1..2cabf34 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2003-08-26 Roger Sayle + PR middle-end/12002 + * g77.f-torture/compile/12002.f: New test case. + +2003-08-26 Roger Sayle + * gcc.dg/20030826-1.c: New test case. 2003-08-26 Matt Kraai diff --git a/gcc/testsuite/g77.f-torture/compile/12002.f b/gcc/testsuite/g77.f-torture/compile/12002.f new file mode 100644 index 0000000..cd66145 --- /dev/null +++ b/gcc/testsuite/g77.f-torture/compile/12002.f @@ -0,0 +1,5 @@ +C PR middle-end/12002 + COMPLEX TE1 + TE1=-2. + TE1=TE1+TE1 + END diff --git a/gcc/tree.h b/gcc/tree.h index 6bceb7c..892057d 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -446,13 +446,21 @@ extern void tree_operand_check_failed (int, enum tree_code, (TREE_CODE (TYPE) == INTEGER_TYPE || TREE_CODE (TYPE) == ENUMERAL_TYPE \ || TREE_CODE (TYPE) == BOOLEAN_TYPE || TREE_CODE (TYPE) == CHAR_TYPE) +/* Nonzero if TYPE represents a scalar floating-point type. */ + +#define SCALAR_FLOAT_TYPE_P(TYPE) (TREE_CODE (TYPE) == REAL_TYPE) + +/* Nonzero if TYPE represents a complex floating-point type. */ + +#define COMPLEX_FLOAT_TYPE_P(TYPE) \ + (TREE_CODE (TYPE) == COMPLEX_TYPE \ + && TREE_CODE (TREE_TYPE (TYPE)) == REAL_TYPE) + /* Nonzero if TYPE represents a floating-point type, including complex floating-point types. */ #define FLOAT_TYPE_P(TYPE) \ - (TREE_CODE (TYPE) == REAL_TYPE \ - || (TREE_CODE (TYPE) == COMPLEX_TYPE \ - && TREE_CODE (TREE_TYPE (TYPE)) == REAL_TYPE)) + (SCALAR_FLOAT_TYPE_P (TYPE) || COMPLEX_FLOAT_TYPE_P (TYPE)) /* Nonzero if TYPE represents an aggregate (multi-component) type. */ -- 2.7.4