This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][4.2] Fix PR31797, make forwprop not propagate into a stmt that has volatile ops
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Sat, 12 May 2007 19:20:04 +0200 (CEST)
- Subject: [PATCH][4.2] Fix PR31797, make forwprop not propagate into a stmt that has volatile ops
This fixes the mentioned PR where we end up with a mismatch between
the stmt annotation (has_volatile_ops) and the tree flags in the stmt
operands (it has TREE_THIS_VOLATILE and TREE_SIDE_EFFECTS set).
Fixed by not creating a stmt that update_stmt () will create this mismatch
for.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
4.2 branch and the trunk.
Richard.
2007-05-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/31797
* tree-ssa-forwprop.c (forward_propagate_addr_expr): Do not
propagate into a stmt that has volatile ops.
* gcc.c-torture/compile/pr31797.c: New testcase.
Index: tree-ssa-forwprop.c
===================================================================
*** tree-ssa-forwprop.c (revision 124635)
--- tree-ssa-forwprop.c (working copy)
*************** forward_propagate_addr_expr (tree stmt,
*** 843,857 ****
continue;
}
! /* If the use is in a deeper loop nest, then we do not want
! to propagate the ADDR_EXPR into the loop as that is likely
! adding expression evaluations into the loop. */
if (bb_for_stmt (use_stmt)->loop_depth > stmt_loop_depth)
{
all = false;
continue;
}
!
result = forward_propagate_addr_expr_1 (stmt, use_stmt, some);
*some |= result;
all &= result;
--- 843,864 ----
continue;
}
! /* If the use is in a deeper loop nest, then we do not want
! to propagate the ADDR_EXPR into the loop as that is likely
! adding expression evaluations into the loop. */
if (bb_for_stmt (use_stmt)->loop_depth > stmt_loop_depth)
{
all = false;
continue;
}
!
! /* If the use_stmt has side-effects, don't propagate into it. */
! if (stmt_ann (use_stmt)->has_volatile_ops)
! {
! all = false;
! continue;
! }
!
result = forward_propagate_addr_expr_1 (stmt, use_stmt, some);
*some |= result;
all &= result;
Index: testsuite/gcc.c-torture/compile/pr31797.c
===================================================================
*** testsuite/gcc.c-torture/compile/pr31797.c (revision 0)
--- testsuite/gcc.c-torture/compile/pr31797.c (revision 0)
***************
*** 0 ****
--- 1,31 ----
+ struct GTeth_desc
+ {
+ unsigned ed_cmdsts;
+ };
+ struct GTeth_softc
+ {
+ struct GTeth_desc txq_desc[32];
+ unsigned int txq_fi;
+ unsigned int txq_nactive;
+ };
+
+ void
+ GTeth_txq_free (struct GTeth_softc *sc)
+ {
+ struct GTeth_desc *txd = &sc->txq_desc[0];
+ txd->ed_cmdsts &= ~(1U << (31));
+ }
+ void
+ GTeth_txq_done (struct GTeth_softc *sc)
+ {
+ while (sc->txq_nactive > 0)
+ {
+ volatile struct GTeth_desc *txd = &sc->txq_desc[sc->txq_fi];
+ if (txd->ed_cmdsts)
+ {
+ if (sc->txq_nactive == 1)
+ return;
+ }
+ GTeth_txq_free (sc);
+ }
+ }