diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-01-25 20:03:54 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2013-01-25 20:03:54 +0000 |
commit | 13898e44a192b0e5e7ef34bab1eb9c68a1d64f2a (patch) | |
tree | 9f912299747d19a0c5f72e447bddfdcbd9149566 | |
parent | cbec6a255e961871c726c3f4ca18560acc38cd46 (diff) |
PR tree-optimization/56098
* tree-ssa-phiopt.c (nt_init_block): Don't call add_or_mark_expr
for stmts with volatile ops.
(cond_store_replacement): Don't optimize if assign has volatile ops.
(cond_if_else_store_replacement_1): Don't optimize if either
then_assign or else_assign have volatile ops.
(hoist_adjacent_loads): Don't optimize if either def1 or def2 have
volatile ops.
* gcc.dg/pr56098-1.c: New test.
* gcc.dg/pr56098-2.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@195475 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr56098-1.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr56098-2.c | 19 | ||||
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 13 |
5 files changed, 61 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 85152febbdc..3897b8d6a7e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2013-01-25 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/56098 + * tree-ssa-phiopt.c (nt_init_block): Don't call add_or_mark_expr + for stmts with volatile ops. + (cond_store_replacement): Don't optimize if assign has volatile ops. + (cond_if_else_store_replacement_1): Don't optimize if either + then_assign or else_assign have volatile ops. + (hoist_adjacent_loads): Don't optimize if either def1 or def2 have + volatile ops. + 2013-01-25 Georg-Johann Lay <avr@gjlay.de> * doc/invoke.texi (AVR Built-in Macros): Document __XMEGA__. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d00476ef161..db9f3679bf8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-01-25 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/56098 + * gcc.dg/pr56098-1.c: New test. + * gcc.dg/pr56098-2.c: New test. + 2013-01-25 Georg-Johann Lay <avr@gjlay.de> PR target/54222 diff --git a/gcc/testsuite/gcc.dg/pr56098-1.c b/gcc/testsuite/gcc.dg/pr56098-1.c new file mode 100644 index 00000000000..c3b081a0899 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr56098-1.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/56098 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +volatile int *p; + +void +foo (int x) +{ + *p = 1; + if (x) + *p = 2; +} + +/* { dg-final { scan-tree-dump-not "=\[^\n\r]*\\*p" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr56098-2.c b/gcc/testsuite/gcc.dg/pr56098-2.c new file mode 100644 index 00000000000..3c967b52507 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr56098-2.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/56098 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fhoist-adjacent-loads -fdump-tree-optimized" } */ + +struct S { volatile int i; volatile int j; }; + +int +bar (struct S *x, int y) +{ + int r; + if (y) + r = x->i; + else + r = x->j; + return r; +} + +/* { dg-final { scan-tree-dump-not "r_\[0-9]* =.v. \[^\n\r]*;\[\n\r]* r_\[0-9]* =.v. " "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 697e33cf5b8..eee497296ca 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1342,7 +1342,7 @@ nt_init_block (struct dom_walk_data *data ATTRIBUTE_UNUSED, basic_block bb) { gimple stmt = gsi_stmt (gsi); - if (gimple_assign_single_p (stmt)) + if (gimple_assign_single_p (stmt) && !gimple_has_volatile_ops (stmt)) { add_or_mark_expr (bb, gimple_assign_lhs (stmt), nontrap_set, true); add_or_mark_expr (bb, gimple_assign_rhs1 (stmt), nontrap_set, false); @@ -1419,7 +1419,8 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, /* Check if middle_bb contains of only one store. */ if (!assign - || !gimple_assign_single_p (assign)) + || !gimple_assign_single_p (assign) + || gimple_has_volatile_ops (assign)) return false; locus = gimple_location (assign); @@ -1490,9 +1491,11 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb, if (then_assign == NULL || !gimple_assign_single_p (then_assign) || gimple_clobber_p (then_assign) + || gimple_has_volatile_ops (then_assign) || else_assign == NULL || !gimple_assign_single_p (else_assign) - || gimple_clobber_p (else_assign)) + || gimple_clobber_p (else_assign) + || gimple_has_volatile_ops (else_assign)) return false; lhs = gimple_assign_lhs (then_assign); @@ -1829,7 +1832,9 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1, /* Both statements must be assignments whose RHS is a COMPONENT_REF. */ if (!gimple_assign_single_p (def1) - || !gimple_assign_single_p (def2)) + || !gimple_assign_single_p (def2) + || gimple_has_volatile_ops (def1) + || gimple_has_volatile_ops (def2)) continue; ref1 = gimple_assign_rhs1 (def1); |