The following fixes PR58432 - I forgot to seed partitions from
PHI nodes that have uses on the exit edge.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2013-09-16  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/58432
        * tree-loop-distribution.c (tree_loop_distribution): Also
        scan PHIs for outside loop uses and seed a partition from them.

        * gcc.dg/pr58432.c: New testcase.

Index: gcc/tree-loop-distribution.c
===================================================================
*** gcc/tree-loop-distribution.c        (revision 202619)
--- gcc/tree-loop-distribution.c        (working copy)
*************** tree_loop_distribution (void)
*** 1676,1681 ****
--- 1676,1692 ----
        for (i = 0; i < loop->num_nodes; ++i)
        {
          gimple_stmt_iterator gsi;
+         for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+           {
+             gimple phi = gsi_stmt (gsi);
+             if (virtual_operand_p (gimple_phi_result (phi)))
+               continue;
+             /* Distribute stmts which have defs that are used outside of
+                the loop.  */
+             if (!stmt_has_scalar_dependences_outside_loop (loop, phi))
+               continue;
+             work_list.safe_push (phi);
+           }
          for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
            {
              gimple stmt = gsi_stmt (gsi);
Index: gcc/testsuite/gcc.dg/pr58432.c
===================================================================
*** gcc/testsuite/gcc.dg/pr58432.c      (revision 0)
--- gcc/testsuite/gcc.dg/pr58432.c      (working copy)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile } */
+ /* { dg-require-profiling "-fprofile-generate" } */
+ /* { dg-options "-O3 -fprofile-generate" } */
+ 
+ struct {
+     int prefix;
+     int dir_idx;
+ } *a;
+ int b;
+ void fn1() {
+     int *c, *d;
+     for (; b; b++)
+       if (d[b]) {
+         c[b] = d[b];
+         a[0].dir_idx = 0;
+       }
+ }

Reply via email to