diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-09-01 18:33:06 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2004-09-01 18:33:06 +0200 |
commit | 266bff3a21f3cce8094152b94ab9f2e6ee565c43 (patch) | |
tree | a9c1c35b561f07ec3e2ed7f0c58c0351e7c7c2b2 /gcc | |
parent | 320785323832777de9ad6161462dbcf3ab27e67f (diff) | |
download | gcc-266bff3a21f3cce8094152b94ab9f2e6ee565c43.zip gcc-266bff3a21f3cce8094152b94ab9f2e6ee565c43.tar.gz gcc-266bff3a21f3cce8094152b94ab9f2e6ee565c43.tar.bz2 |
fold-const.c (operand_equal_p): Require equal sign also for FIX_{CEIL,TRUNC,FLOOR,ROUND}_EXPR.
* fold-const.c (operand_equal_p): Require equal sign also for
FIX_{CEIL,TRUNC,FLOOR,ROUND}_EXPR.
* gcc.c-torture/execute/20040831-1.c: New test.
From-SVN: r86906
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20040831-1.c | 14 |
4 files changed, 38 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1218332..dccd34a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-09-01 Jakub Jelinek <jakub@redhat.com> + + * fold-const.c (operand_equal_p): Require equal sign also for + FIX_{CEIL,TRUNC,FLOOR,ROUND}_EXPR. + 2004-09-01 Richard Earnshaw <rearnsha@arm.com> * config.gcc (--with-cpu on ARM): Preserve the canonical cpu name diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3ee2bc7..1ccea7e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2391,10 +2391,21 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) { case '1': /* Two conversions are equal only if signedness and modes match. */ - if ((TREE_CODE (arg0) == NOP_EXPR || TREE_CODE (arg0) == CONVERT_EXPR) - && (TYPE_UNSIGNED (TREE_TYPE (arg0)) - != TYPE_UNSIGNED (TREE_TYPE (arg1)))) - return 0; + switch (TREE_CODE (arg0)) + { + case NOP_EXPR: + case CONVERT_EXPR: + case FIX_CEIL_EXPR: + case FIX_TRUNC_EXPR: + case FIX_FLOOR_EXPR: + case FIX_ROUND_EXPR: + if (TYPE_UNSIGNED (TREE_TYPE (arg0)) + != TYPE_UNSIGNED (TREE_TYPE (arg1))) + return 0; + break; + default: + break; + } return operand_equal_p (TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0), flags); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2fdc6a..53ee056 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-09-01 Jakub Jelinek <jakub@redhat.com> + + * gcc.c-torture/execute/20040831-1.c: New test. + 2004-09-01 David Billinghurst <David.Billinghurst@riotinto.com> PR fortran/16579 diff --git a/gcc/testsuite/gcc.c-torture/execute/20040831-1.c b/gcc/testsuite/gcc.c-torture/execute/20040831-1.c new file mode 100644 index 0000000..39773b3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20040831-1.c @@ -0,0 +1,14 @@ +/* This testcase was being miscompiled, because operand_equal_p + returned that (unsigned long) d and (long) d are equal. */ +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + double d = -12.0; + long l = (d > 10000) ? (unsigned long) d : (long) d; + if (l != -12) + abort (); + exit (0); +} |