This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Re-enable store-motion, fix PRs 36204 and 36009
On Thu, 15 May 2008, Zdenek Dvorak wrote:
> Hi,
>
> > > > I still do not understand -- the proposed change to movement_possibility
> > > > does not seem to affect load motion, either?
> > >
> > > The problem is that determine_invariantness_stmt sets up LIM_DATA but
> > > skips MOVE_IMPOSSIBLE stmts, so later during store-motion we check
> > > ref_always_accessed_p (called from can_sm_ref_p) which says no if the
> > > store is the only stmt accessing the location.
> > >
> > > So fixing movement_possibility enables determine_invariantness_stmt to
> > > do its work.
>
> ok, thanks for investigating this.
>
> > Or something like the following, which also fixes this problem.
> > (I'll polish that up)
>
> I think this is safer; ok after polishing (and bootstrapping and
> regtesting),
This is what I applied after bootstrapping and regtesting on
x86_64-unknown-linux-gnu.
Richard.
2008-05-15 Richard Guenther <rguenther@suse.de>
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..
Index: testsuite/gcc.dg/tree-ssa/ssa-lim-6.c
===================================================================
*** testsuite/gcc.dg/tree-ssa/ssa-lim-6.c (revision 0)
--- testsuite/gcc.dg/tree-ssa/ssa-lim-6.c (revision 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" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-lim-5.c
===================================================================
*** testsuite/gcc.dg/tree-ssa/ssa-lim-5.c (revision 0)
--- testsuite/gcc.dg/tree-ssa/ssa-lim-5.c (revision 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; }
Index: tree-ssa-loop-im.c
===================================================================
*** tree-ssa-loop-im.c (revision 135297)
--- tree-ssa-loop-im.c (working copy)
*************** along with GCC; see the file COPYING3.
*** 40,45 ****
--- 40,46 ----
#include "hashtab.h"
#include "tree-affine.h"
#include "pointer-set.h"
+ #include "tree-ssa-propagate.h"
/* TODO: Support for predicated code motion. I.e.
*************** determine_invariantness_stmt (struct dom
*** 900,905 ****
--- 901,914 ----
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;
}
Index: Makefile.in
===================================================================
*** Makefile.in (revision 135297)
--- Makefile.in (working copy)
*************** tree-ssa-loop-im.o : tree-ssa-loop-im.c
*** 2206,2212 ****
$(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
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)
--- 2206,2212 ----
$(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 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)