diff options
author | Richard Guenther <rguenther@suse.de> | 2006-10-23 07:15:45 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-10-23 07:15:45 +0000 |
commit | 4f76e46b189899f58e018dec68d7f5e68a6e55a2 (patch) | |
tree | 7d9beeeaa99bee3c5a1fbb22e70da00ea720cc71 /gcc | |
parent | 1b406eadf9697727eb412f11ecae8d691e54a562 (diff) | |
download | gcc-4f76e46b189899f58e018dec68d7f5e68a6e55a2.zip gcc-4f76e46b189899f58e018dec68d7f5e68a6e55a2.tar.gz gcc-4f76e46b189899f58e018dec68d7f5e68a6e55a2.tar.bz2 |
re PR middle-end/21032 (With -frounding-math, incorrectly reorders unary minus)
2006-10-23 Richard Guenther <rguenther@suse.de>
PR middle-end/21032
* convert.c (convert_to_real): Fold (float)-x to -(float)x
only if not flag_rounding_math.
* gcc.dg/pr21032.c: New testcase.
From-SVN: r117968
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/convert.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr21032.c | 11 |
4 files changed, 26 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3288755..655596d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-10-23 Richard Guenther <rguenther@suse.de> + + PR middle-end/21032 + * convert.c (convert_to_real): Fold (float)-x to -(float)x + only if not flag_rounding_math. + 2006-10-22 Richard Sandiford <richard@codesourcery.com> Kaz Kojima <kkojima@gcc.gnu.org> diff --git a/gcc/convert.c b/gcc/convert.c index 118889f..0a9743a 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -248,10 +248,12 @@ convert_to_real (tree type, tree expr) if (itype != type && FLOAT_TYPE_P (type)) switch (TREE_CODE (expr)) { - /* Convert (float)-x into -(float)x. This is always safe. */ + /* Convert (float)-x into -(float)x. This is safe for + round-to-nearest rounding mode. */ case ABS_EXPR: case NEGATE_EXPR: - if (TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr))) + if (!flag_rounding_math + && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr))) return build1 (TREE_CODE (expr), type, fold (convert_to_real (type, TREE_OPERAND (expr, 0)))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 860107e..06d1abc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-10-23 Richard Guenther <rguenther@suse.de> + + PR middle-end/21032 + * gcc.dg/pr21032.c: New testcase. + 2006-10-22 Jeff Law <law@redhat.com> Richard Guenther <rguenther@suse.de> diff --git a/gcc/testsuite/gcc.dg/pr21032.c b/gcc/testsuite/gcc.dg/pr21032.c new file mode 100644 index 0000000..839a180 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr21032.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized -frounding-math" } */ + +void bar(float x); +void foo(double x) +{ + bar(-x); +} + +/* { dg-final { scan-tree-dump-not "-\\(float\\)" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ |