diff options
author | Maxim Kuvyrkov <maxim@codesourcery.com> | 2010-04-08 08:20:36 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <mkuvyrkov@gcc.gnu.org> | 2010-04-08 08:20:36 +0000 |
commit | b0aef8a83c2d6deb4040c46b60f04f224894f058 (patch) | |
tree | 6ce00310b5e89f1a541aa38b1128562367380e03 /gcc | |
parent | 0b2de948243781018a9d292d0b1ebdbf3c8cbb31 (diff) | |
download | gcc-b0aef8a83c2d6deb4040c46b60f04f224894f058.zip gcc-b0aef8a83c2d6deb4040c46b60f04f224894f058.tar.gz gcc-b0aef8a83c2d6deb4040c46b60f04f224894f058.tar.bz2 |
re PR middle-end/40815 (redundant neg instruction caused by loop-invariant)
PR middle-end/40815
* tree-ssa-reassoc.c (broken_up_substracts): Rename to plus_negates.
(negate_value): Move code to push elements to broken_up_substracts ...
(eliminate_plus_minus_pair): ... here. Push operands that have no
negative pair to plus_negates.
(repropagate_negates, init_reassoc, fini_reassoc): Update.
PR middle-end/40815
* gcc.dg/tree-ssa/reassoc-19.c: New.
From-SVN: r158105
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c | 21 | ||||
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 15 |
4 files changed, 44 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6f2b7e0..fc4a4a9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-04-08 Maxim Kuvyrkov <maxim@codesourcery.com> + + PR middle-end/40815 + * tree-ssa-reassoc.c (broken_up_substracts): Rename to plus_negates. + (negate_value): Move code to push elements to broken_up_substracts ... + (eliminate_plus_minus_pair): ... here. Push operands that have no + negative pair to plus_negates. + (repropagate_negates, init_reassoc, fini_reassoc): Update. + 2010-04-07 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * doc/install.texi (Configuration): Move description of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d4ea278..30ee707 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-08 Maxim Kuvyrkov <maxim@codesourcery.com> + + PR middle-end/40815 + * gcc.dg/tree-ssa/reassoc-19.c: New. + 2010-04-07 Jakub Jelinek <jakub@redhat.com> PR c/18624 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c new file mode 100644 index 0000000..c13e1d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fdump-tree-reassoc2" } */ + +/* Slightly changed testcase from PR middle-end/40815. */ +void bar(char*, char*, int); +void foo(char* left, char* rite, int element) +{ + while (left <= rite) + { + /* This should expand into + D.zzzz = D.zzzz - D.xxxx; + and NOT to + D.D.yyyy = -D.xxxx; D.zzzz = D.zzzz + D.yyyy; */ + rite -= element; + bar(left, rite, element); + } +} + +/* There should be no " + " in the dump. */ +/* { dg-final { scan-tree-dump-times " \\\+ " 0 "reassoc2" } } */ +/* { dg-final { cleanup-tree-dump "reassoc2" } } */ diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 5f7c6b7..cf05de5 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -467,6 +467,8 @@ eliminate_duplicate_pair (enum tree_code opcode, return false; } +static VEC(tree, heap) *plus_negates; + /* If OPCODE is PLUS_EXPR, CURR->OP is really a negate expression, look in OPS for a corresponding positive operation to cancel it out. If we find one, remove the other from OPS, replace @@ -521,6 +523,10 @@ eliminate_plus_minus_pair (enum tree_code opcode, } } + /* CURR->OP is a negate expr in a plus expr: save it for later + inspection in repropagate_negates(). */ + VEC_safe_push (tree, heap, plus_negates, curr->op); + return false; } @@ -1500,8 +1506,6 @@ get_single_immediate_use (tree lhs) return NULL; } -static VEC(tree, heap) *broken_up_subtracts; - /* Recursively negate the value of TONEGATE, and return the SSA_NAME representing the negated value. Insertions of any necessary instructions go before GSI. @@ -1544,7 +1548,6 @@ negate_value (tree tonegate, gimple_stmt_iterator *gsi) tonegate = fold_build1 (NEGATE_EXPR, TREE_TYPE (tonegate), tonegate); resultofnegate = force_gimple_operand_gsi (gsi, tonegate, true, NULL_TREE, true, GSI_SAME_STMT); - VEC_safe_push (tree, heap, broken_up_subtracts, resultofnegate); return resultofnegate; } @@ -1700,7 +1703,7 @@ repropagate_negates (void) unsigned int i = 0; tree negate; - for (i = 0; VEC_iterate (tree, broken_up_subtracts, i, negate); i++) + for (i = 0; VEC_iterate (tree, plus_negates, i, negate); i++) { gimple user = get_single_immediate_use (negate); @@ -2014,7 +2017,7 @@ init_reassoc (void) free (bbs); calculate_dominance_info (CDI_POST_DOMINATORS); - broken_up_subtracts = NULL; + plus_negates = NULL; } /* Cleanup after the reassociation pass, and print stats if @@ -2035,7 +2038,7 @@ fini_reassoc (void) pointer_map_destroy (operand_rank); free_alloc_pool (operand_entry_pool); free (bb_rank); - VEC_free (tree, heap, broken_up_subtracts); + VEC_free (tree, heap, plus_negates); free_dominance_info (CDI_POST_DOMINATORS); loop_optimizer_finalize (); } |