This fixes PR60785 where we tried to insert a stmt right after
the definition of a default def (oops).  That can't work and
is even wrong, so the patch avoids this.

There is still possibly wrong-code going on here for a loop
like

  b = foo ();
  x = 0;
  do {
    ...
    x = b;
  } while (...);

which also will insert the out-of-SSA copy of the

  x = PHI <0(entry), b(latch)>

PHI after the definition of b.  This only works when
the definition is inside the loop.

I didn't fix that with this patch (no testcase).

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

Richard.

2014-04-08  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/60785
        * graphite-sese-to-poly.c (rewrite_phi_out_of_ssa): Treat
        default defs properly.

        * gcc.dg/graphite/pr60785.c: New testcase.

Index: gcc/graphite-sese-to-poly.c
===================================================================
*** gcc/graphite-sese-to-poly.c (revision 209210)
--- gcc/graphite-sese-to-poly.c (working copy)
*************** rewrite_phi_out_of_ssa (scop_p scop, gim
*** 2250,2255 ****
--- 2250,2256 ----
        /* Avoid the insertion of code in the loop latch to please the
         pattern matching of the vectorizer.  */
        if (TREE_CODE (arg) == SSA_NAME
+         && !SSA_NAME_IS_DEFAULT_DEF (arg)
          && e->src == bb->loop_father->latch)
        insert_out_of_ssa_copy (scop, zero_dim_array, arg,
                                SSA_NAME_DEF_STMT (arg));
Index: gcc/testsuite/gcc.dg/graphite/pr60785.c
===================================================================
*** gcc/testsuite/gcc.dg/graphite/pr60785.c     (revision 0)
--- gcc/testsuite/gcc.dg/graphite/pr60785.c     (working copy)
***************
*** 0 ****
--- 1,27 ----
+ /* { dg-options "-O2 -floop-interchange" } */
+ 
+ static int
+ aqc(void)
+ {
+   return 1;
+ }
+ 
+ void
+ gkd(void)
+ {
+   int wu0;
+   static int b1y;
+   static int gw2;
+   static int *ydw = &gw2;
+   static int **m3l = &ydw;
+   **m3l = 0;
+   for (b1y = 0; b1y < 1; ++b1y)
+     {
+       int *cpj = &gw2;
+       if (*ydw |= aqc())
+       {
+         *cpj = 0;
+         *ydw = wu0;
+       }
+     }
+ }

Reply via email to