This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Re-enable store-motion, fix PRs 36204 and 36009
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Zdenek Dvorak <ook at ucw dot cz>
- Date: Wed, 14 May 2008 16:19:51 +0200 (CEST)
- Subject: [PATCH] Re-enable store-motion, fix PRs 36204 and 36009
This re-enables store-motion for the cases in the PRs which was disabled
by the alias oracle patch hunk
(movement_possibility): Do not allow moving statements
that store to memory.
Bootstrapped and tested on x86_64-unknown-linux-gnu (I also tested
a variant that returns NULL in mem_ref_in_stmt for stores which also
works).
Zdenek, does this look ok or was there a particular reason for the
above hunk?
Thanks,
Richard.
2008-05-14 Richard Guenther <rguenther@suse.de>
PR tree-optimization/36009
PR tree-optimization/36204
* tree-ssa-loop-im.c (movement_possibility): Allow stores again.
(mem_ref_in_stmt): For a store return NULL.
* 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 135264)
--- tree-ssa-loop-im.c (working copy)
*************** movement_possibility (tree stmt)
*** 314,322 ****
if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
return MOVE_IMPOSSIBLE;
- if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_VIRTUAL_DEFS))
- return MOVE_IMPOSSIBLE;
-
if (stmt_ends_bb_p (stmt))
return MOVE_IMPOSSIBLE;
--- 314,319 ----
*************** mem_ref_in_stmt (tree stmt)
*** 614,620 ****
if (!mem)
return NULL;
- gcc_assert (!store);
hash = iterative_hash_expr (*mem, 0);
ref = htab_find_with_hash (memory_accesses.refs, *mem, hash);
--- 611,616 ----