Find matched aggregate lattice for self-recursive CP (PR ipa/93084)
authorFeng Xue <fxue@os.amperecomputing.com>
Wed, 8 Jan 2020 02:55:00 +0000 (02:55 +0000)
committerFeng Xue <fxue@gcc.gnu.org>
Wed, 8 Jan 2020 02:55:00 +0000 (02:55 +0000)
2020-01-08  Feng Xue  <fxue@os.amperecomputing.com>

        PR ipa/93084
        * ipa-cp.c (self_recursively_generated_p): Find matched aggregate
        lattice for a value to check.
        (propagate_vals_across_arith_jfunc): Add an assertion to ensure
        finite propagation in self-recursive scc.

2020-01-08  Feng Xue  <fxue@os.amperecomputing.com>

        PR ipa/93084
        * gcc.dg/ipa/ipa-clone-3.c: New test.

From-SVN: r279987

gcc/ChangeLog
gcc/ipa-cp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/ipa-clone-3.c [new file with mode: 0644]

index 44ae44c82609c5764ecf1b1db078f03e2a8b1d94..6387fcc9abaf508ff4fac05687d53dda49b50305 100644 (file)
@@ -1,3 +1,11 @@
+2020-01-08  Feng Xue  <fxue@os.amperecomputing.com>
+
+       PR ipa/93084
+       * ipa-cp.c (self_recursively_generated_p): Find matched aggregate
+       lattice for a value to check.
+       (propagate_vals_across_arith_jfunc): Add an assertion to ensure
+       finite propagation in self-recursive scc.
+
 2020-01-08  Luo Xiong Hu  <luoxhu@linux.ibm.com>
 
        * ipa-inline.c (caller_growth_limits): Restore the AND.
index 4381b35a8095787b10213209371575b5f4c2892d..1163198629384a8f7f7c7cd7e61ddf467bb52862 100644 (file)
@@ -1917,10 +1917,25 @@ self_recursively_generated_p (ipcp_value<tree> *val)
 
       class ipcp_param_lattices *plats = ipa_get_parm_lattices (info,
                                                                src->index);
-      ipcp_lattice<tree> *src_lat = src->offset == -1 ? &plats->itself
-                                                     : plats->aggs;
+      ipcp_lattice<tree> *src_lat;
       ipcp_value<tree> *src_val;
 
+      if (src->offset == -1)
+       src_lat = &plats->itself;
+      else
+       {
+         struct ipcp_agg_lattice *src_aglat;
+
+         for (src_aglat = plats->aggs; src_aglat; src_aglat = src_aglat->next)
+           if (src_aglat->offset == src->offset)
+             break;
+
+         if (!src_aglat)
+           return false;
+
+         src_lat = src_aglat;
+       }
+
       for (src_val = src_lat->values; src_val; src_val = src_val->next)
        if (src_val == val)
          break;
@@ -2017,6 +2032,8 @@ propagate_vals_across_arith_jfunc (cgraph_edge *cs,
            val_seeds.safe_push (src_val);
        }
 
+      gcc_assert ((int) val_seeds.length () <= param_ipa_cp_value_list_size);
+
       /* Recursively generate lattice values with a limited count.  */
       FOR_EACH_VEC_ELT (val_seeds, i, src_val)
        {
index ec35056910bd5575034ca030be925d1c14341bc1..8ee00cebcfcc6dea0acaa96bc3f22115dd11e893 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-08  Feng Xue  <fxue@os.amperecomputing.com>
+
+       PR ipa/93084
+       * gcc.dg/ipa/ipa-clone-3.c: New test.
+
 2020-01-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.old-deja/g++.bugs/900208_03.C: Check locations too.
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-clone-3.c b/gcc/testsuite/gcc.dg/ipa/ipa-clone-3.c
new file mode 100644 (file)
index 0000000..18d29bd
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-ipa-cp-details -fno-early-inlining --param ipa-cp-max-recursive-depth=8 --param ipa-cp-eval-threshold=1" } */
+
+struct V {
+  int f0;
+  int f1;
+};
+
+int data[100];
+
+int fn ();
+
+int recur_fn (struct V * __restrict v)
+{
+  int i = v->f0;
+  int j = v->f1;
+  struct V t;
+
+  if (j > 100)
+    {
+      fn ();
+      return 1;
+    }
+
+  data[i] = i;
+
+  t.f0 = i - 2;
+  t.f1 = j + 1;
+
+  recur_fn (&t);
+
+  return i * j;
+}
+
+int main ()
+{
+  struct V v = {1, 3};
+
+  return recur_fn (&v);
+}
+
+/* { dg-final { scan-ipa-dump-times "Creating a specialized node of recur_fn/\[0-9\]*\\." 8 "cp" } } */