From: Jakub Jelinek Date: Wed, 1 Sep 2004 16:33:06 +0000 (+0200) Subject: fold-const.c (operand_equal_p): Require equal sign also for FIX_{CEIL,TRUNC,FLOOR... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=266bff3a21f3cce8094152b94ab9f2e6ee565c43;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 12183328e21..dccd34a932b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-09-01 Jakub Jelinek + + * fold-const.c (operand_equal_p): Require equal sign also for + FIX_{CEIL,TRUNC,FLOOR,ROUND}_EXPR. + 2004-09-01 Richard Earnshaw * config.gcc (--with-cpu on ARM): Preserve the canonical cpu name diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3ee2bc746e3..1ccea7e69b3 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 d2fdc6a4a0b..53ee056ae53 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-09-01 Jakub Jelinek + + * gcc.c-torture/execute/20040831-1.c: New test. + 2004-09-01 David Billinghurst 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 00000000000..39773b34ba3 --- /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); +}