From a973ed421c593521a7b20b9dee2ad60ab8876ba7 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 15 May 2008 08:37:22 +0000 Subject: [PATCH] 2008-05-15 Richard Guenther PR tree-optimization/36009 PR tree-optimization/36204 * tree-ssa-loop-im.c (tree-ssa-propagate.h): Include. (determine_invariantness_stmt): Record the loop a store is always executed in. * Makefile.in (tree-ssa-loop-im.o): Add tree-ssa-propagate.h dependency. * gcc.dg/tree-ssa/ssa-lim-5.c: New testcase. * gcc.dg/tree-ssa/ssa-lim-6.c: Likewise.. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135330 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 10 ++++++++++ gcc/Makefile.in | 2 +- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-5.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-6.c | 14 ++++++++++++++ gcc/tree-ssa-loop-im.c | 9 +++++++++ 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-5.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-6.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7451ace922f..74c5765d266 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 2008-05-15 Richard Guenther + PR tree-optimization/36009 + PR tree-optimization/36204 + * tree-ssa-loop-im.c (tree-ssa-propagate.h): Include. + (determine_invariantness_stmt): Record the loop a store is + always executed in. + * Makefile.in (tree-ssa-loop-im.o): Add tree-ssa-propagate.h + dependency. + +2008-05-15 Richard Guenther + PR tree-optimization/34330 * tree-ssa-alias.c (get_smt_for): Only assert that accesses through the pointer will alias the SMT. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 84bc2352b2a..f981b1eef5e 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2206,7 +2206,7 @@ tree-ssa-loop-im.o : tree-ssa-loop-im.c $(TREE_FLOW_H) $(CONFIG_H) \ $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(CFGLOOP_H) domwalk.h \ $(PARAMS_H) output.h $(DIAGNOSTIC_H) $(TIMEVAR_H) $(TM_H) coretypes.h \ $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) $(REAL_H) $(BASIC_BLOCK_H) \ - hard-reg-set.h + hard-reg-set.h tree-ssa-propagate.h tree-ssa-math-opts.o : tree-ssa-math-opts.c $(TREE_FLOW_H) $(CONFIG_H) \ $(SYSTEM_H) $(TREE_H) $(TIMEVAR_H) tree-pass.h $(TM_H) $(FLAGS_H) \ alloc-pool.h $(BASIC_BLOCK_H) $(TARGET_H) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8215e221cd2..d8c7caedc5e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2008-05-15 Richard Guenther + PR tree-optimization/36009 + PR tree-optimization/36204 + * gcc.dg/tree-ssa/ssa-lim-5.c: New testcase. + * gcc.dg/tree-ssa/ssa-lim-6.c: Likewise.. + +2008-05-15 Richard Guenther + PR tree-optimization/34330 * gcc.dg/torture/pr34330.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-5.c new file mode 100644 index 00000000000..18ca905bf8e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-5.c @@ -0,0 +1,25 @@ +/* { dg-do link } */ +/* { dg-options "-O" } */ + +/* We should apply store motion here. */ + +struct BUF1 +{ + int b1; + int b12; +}; + +void link_error(); + +int foo(struct BUF1 * p) +{ + + int i = 0; + for (i = 0; i < 1024*1024; i++) + p->b1 = 1; + if (p->b1 != 1) + link_error (); + return 0; +} + +int main() { return 0; } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-6.c new file mode 100644 index 00000000000..0da57aa087d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-6.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-lim-details" } */ + +double a[16][64], y[64], x[16]; +void foo(void) +{ + int i, j; + for (j = 0; j < 64; ++j) + for (i = 0; i < 16; ++i) + y[j] = y[j] + a[i][j] * x[i]; +} + +/* { dg-final { scan-tree-dump "Executing store motion of y" "lim" } } */ +/* { dg-final { cleanup-tree-dump "lim" } } */ diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index ba36343f548..8740030397f 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "hashtab.h" #include "tree-affine.h" #include "pointer-set.h" +#include "tree-ssa-propagate.h" /* TODO: Support for predicated code motion. I.e. @@ -900,6 +901,14 @@ determine_invariantness_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED, maybe_never = true; outermost = NULL; } + /* Make sure to note always_executed_in for stores to make + store-motion work. */ + else if (stmt_makes_single_store (stmt)) + { + stmt_ann (stmt)->common.aux + = xcalloc (1, sizeof (struct lim_aux_data)); + LIM_DATA (stmt)->always_executed_in = outermost; + } continue; } -- 2.11.0