diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-08-05 21:26:27 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-08-05 21:26:27 +0200 |
commit | 1bed5ee327933809acc2bb4a95fdcf8254d7ffa5 (patch) | |
tree | a306730481abb5c80e103e5c05910fd1b4693506 /gcc/fold-const.c | |
parent | 5133ad466a642ee5080d8632fc8fca21478362bf (diff) | |
download | gcc-1bed5ee327933809acc2bb4a95fdcf8254d7ffa5.zip gcc-1bed5ee327933809acc2bb4a95fdcf8254d7ffa5.tar.gz gcc-1bed5ee327933809acc2bb4a95fdcf8254d7ffa5.tar.bz2 |
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: r56058
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 7751e65..033dbfcf 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1001,14 +1001,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))); |