From: Jakub Jelinek Date: Wed, 4 Dec 2002 19:28:27 +0000 (+0100) Subject: fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one of the operands... X-Git-Tag: releases/gcc-3.2.2~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a68ba83e72202cb1e0950be292af0179ada47bd6;p=thirdparty%2Fgcc.git fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one of the operands into MINUS_EXPR if... * fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one of the operands into MINUS_EXPR if code is PLUS_EXPR. * gcc.c-torture/execute/20020805-1.c: New test. From-SVN: r59824 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5cc30eb55d5e..7a27c2fd34d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-12-04 Jakub Jelinek + + * fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one + of the operands into MINUS_EXPR if code is PLUS_EXPR. + 2002-12-02 Bob Wilson * config/xtensa/xtensa.c (xtensa_emit_call): Use a static buffer. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 021faf58e7f6..ef247174d912 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1500,14 +1500,16 @@ associate_trees (t1, t2, code, type) if (TREE_CODE (t1) == code || TREE_CODE (t2) == code || TREE_CODE (t1) == MINUS_EXPR || TREE_CODE (t2) == MINUS_EXPR) { - if (TREE_CODE (t1) == NEGATE_EXPR) - return build (MINUS_EXPR, type, convert (type, t2), - convert (type, TREE_OPERAND (t1, 0))); - else if (TREE_CODE (t2) == NEGATE_EXPR) - return build (MINUS_EXPR, type, convert (type, t1), - convert (type, TREE_OPERAND (t2, 0))); - else - return build (code, type, convert (type, t1), convert (type, t2)); + if (code == PLUS_EXPR) + { + if (TREE_CODE (t1) == NEGATE_EXPR) + return build (MINUS_EXPR, type, convert (type, t2), + convert (type, TREE_OPERAND (t1, 0))); + else if (TREE_CODE (t2) == NEGATE_EXPR) + return build (MINUS_EXPR, type, convert (type, t1), + convert (type, TREE_OPERAND (t2, 0))); + } + return build (code, type, convert (type, t1), convert (type, t2)); } return fold (build (code, type, convert (type, t1), convert (type, t2))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bd154a8c7ac5..5616ee408dc4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-12-04 Jakub Jelinek + + * gcc.c-torture/execute/20020805-1.c: New test. + 2002-12-02 Mark Mitchell PR c++/8615