diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-05-07 09:40:01 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-05-07 09:40:01 +0200 |
commit | f61edbf65f93da4d4c1d7c3f201b39dc85d982c2 (patch) | |
tree | 4931bfe9c77a6c8047f0ddbf95b8af43821d7528 /gcc | |
parent | c18c98c0ade56bc46ce65bbf5cdff26a2577c990 (diff) | |
download | gcc-f61edbf65f93da4d4c1d7c3f201b39dc85d982c2.zip gcc-f61edbf65f93da4d4c1d7c3f201b39dc85d982c2.tar.gz gcc-f61edbf65f93da4d4c1d7c3f201b39dc85d982c2.tar.bz2 |
re PR middle-end/36137 (gcc can't do math)
PR middle-end/36137
* fold-const.c (fold_binary): Use STRIP_SIGN_NOPS instead of
STRIP_NOPS on arguments even for MIN_EXPR and MAX_EXPR.
* gcc.c-torture/execute/20080506-1.c: New test.
From-SVN: r135028
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fold-const.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20080506-1.c | 21 |
4 files changed, 34 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6147e35..20ee05c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,14 +1,14 @@ 2008-05-07 Jakub Jelinek <jakub@redhat.com> + PR middle-end/36137 + * fold-const.c (fold_binary): Use STRIP_SIGN_NOPS instead of + STRIP_NOPS on arguments even for MIN_EXPR and MAX_EXPR. + PR middle-end/36106 * omp-low.c (expand_omp_atomic_pipeline): Load value using the integral type rather than floating point, then VIEW_CONVERT_EXPR to the floating point type. - * testsuite/libgomp.c/atomic-5.c: New test. - * testsuite/libgomp.c/atomic-6.c: New test. - * testsuite/libgomp.c/autopar-1.c: New test. - 2008-05-07 Uros Bizjak <ubizjak@gmail.com> * config/i386/i386.c (ix86_expand_copysign): Force non-zero constant diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b4645ca..db7be87 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1,6 +1,6 @@ /* Fold a constant sub-tree into a single node for C-compiler Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GCC. @@ -9261,7 +9261,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) safe for every expression, except for a comparison expression because its signedness is derived from its operands. So, in the latter case, only strip conversions that don't change the - signedness. + signedness. MIN_EXPR/MAX_EXPR also need signedness of arguments + preserved. Note that this is done as an internal manipulation within the constant folder, in order to find the simplest representation @@ -9269,7 +9270,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) cases, the appropriate type conversions should be put back in the tree that will get out of the constant folder. */ - if (kind == tcc_comparison) + if (kind == tcc_comparison || code == MIN_EXPR || code == MAX_EXPR) { STRIP_SIGN_NOPS (arg0); STRIP_SIGN_NOPS (arg1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e2d2bb8..a36aa5a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-05-07 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/36137 + * gcc.c-torture/execute/20080506-1.c: New test. + 2008-05-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/34974 diff --git a/gcc/testsuite/gcc.c-torture/execute/20080506-1.c b/gcc/testsuite/gcc.c-torture/execute/20080506-1.c new file mode 100644 index 0000000..4f6d6d8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20080506-1.c @@ -0,0 +1,21 @@ +/* PR middle-end/36137 */ +extern void abort (void); + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +int +main () +{ + unsigned int u; + int i = -1; + + u = MAX ((unsigned int) MAX (i, 0), 1); + if (u != 1) + abort (); + + u = MIN ((unsigned int) MAX (i, 0), (unsigned int) i); + if (u != 0) + abort (); + return 0; +} |