The loop combining partitions because of cost modeling is too optimistic
in skipping partition pairs to check.  The hoisting patch exposes this,
the following fixes it.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2016-07-05  Richard Biener  <rguent...@suse.de>

        * tree-loop-distribution.c (distribute_loop): Fix issue with
        the cost model loop.

Index: gcc/tree-loop-distribution.c
===================================================================
*** gcc/tree-loop-distribution.c        (revision 237955)
--- gcc/tree-loop-distribution.c        (working copy)
*************** distribute_loop (struct loop *loop, vec<
*** 1504,1509 ****
--- 1517,1523 ----
       memory accesses.  */
    for (i = 0; partitions.iterate (i, &into); ++i)
      {
+       bool changed = false;
        if (partition_builtin_p (into))
        continue;
        for (int j = i + 1;
*************** distribute_loop (struct loop *loop, vec<
*** 1524,1531 ****
--- 1538,1552 ----
              partitions.unordered_remove (j);
              partition_free (partition);
              j--;
+             changed = true;
            }
        }
+       /* If we fused 0 1 2 in step 1 to 0,2 1 as 0 and 2 have similar
+          accesses when 1 and 2 have similar accesses but not 0 and 1
+        then in the next iteration we will fail to consider merging
+        1 into 0,2.  So try again if we did any merging into 0.  */
+       if (changed)
+       i--;
      }
  
    /* Build the partition dependency graph.  */

Reply via email to