Fix IPA-CP test for self-feeding recursive dependency
authorMartin Jambor <mjambor@suse.cz>
Fri, 20 Apr 2018 09:35:33 +0000 (11:35 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 20 Apr 2018 09:35:33 +0000 (11:35 +0200)
2018-04-20  Martin Jambor  <mjambor@suse.cz>

ipa/85449
* ipa-cp.c (cgraph_edge_brings_value_p): Move check for self-feeding
recursion dependency to only apply to non-clones.

testsuite/
* gcc.dg/ipa/pr85449.c: New test.

From-SVN: r259518

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

index a244199..e06c6bc 100644 (file)
@@ -1,5 +1,11 @@
 2018-04-20  Martin Jambor  <mjambor@suse.cz>
 
+       ipa/85449
+       * ipa-cp.c (cgraph_edge_brings_value_p): Move check for self-feeding
+       recursion dependency to only apply to non-clones.
+
+2018-04-20  Martin Jambor  <mjambor@suse.cz>
+
        ipa/85447
        * ipa-cp.c (create_specialized_node): Check that clones of
        self-recursive edges exist during IPA-CP.
index 9388482..1b8f335 100644 (file)
@@ -3489,9 +3489,8 @@ cgraph_edge_brings_value_p (cgraph_edge *cs, ipcp_value_source<tree> *src,
       || availability <= AVAIL_INTERPOSABLE
       || caller_info->node_dead)
     return false;
-  /* At the moment we do not propagate over arithmetic jump functions in SCCs,
-     so it is safe to detect self-feeding recursive calls in this way.  */
-  if (!src->val || src->val == dest_val)
+
+  if (!src->val)
     return true;
 
   if (caller_info->ipcp_orig_node)
@@ -3506,6 +3505,12 @@ cgraph_edge_brings_value_p (cgraph_edge *cs, ipcp_value_source<tree> *src,
     }
   else
     {
+      /* At the moment we do not propagate over arithmetic jump functions in
+        SCCs, so it is safe to detect self-feeding recursive calls in this
+        way.  */
+      if (src->val == dest_val)
+       return true;
+
       struct ipcp_agg_lattice *aglat;
       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (caller_info,
                                                                 src->index);
index 92b40fe..4e66877 100644 (file)
@@ -1,5 +1,10 @@
 2018-04-20  Martin Jambor  <mjambor@suse.cz>
 
+       ipa/85449
+       * gcc.dg/ipa/pr85449.c: New test.
+
+2018-04-20  Martin Jambor  <mjambor@suse.cz>
+
        ipa/85447
        * g++.dg/ipa/pr85447.C: New file.
        * gcc.dg/ipa/ipcp-self-recursion-1.c: Likewise.
diff --git a/gcc/testsuite/gcc.dg/ipa/pr85449.c b/gcc/testsuite/gcc.dg/ipa/pr85449.c
new file mode 100644 (file)
index 0000000..57dfce2
--- /dev/null
@@ -0,0 +1,90 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-early-inlining"  } */
+
+int array[128];
+
+volatile int v = 0;
+volatile int blah = 0;
+
+int __attribute__((noipa))
+obscured_zero ()
+{
+  return 0;
+}
+
+int __attribute__((noipa))
+obscured_one ()
+{
+  return 1;
+}
+
+int __attribute__((noipa))
+obscured_two ()
+{
+  return 2;
+}
+
+static
+void cb1 (int l)
+{
+  v = 25;
+}
+
+static
+void cb2 (int l)
+{
+  v = 125;
+}
+
+typedef void (*silly_callback)(int);
+
+silly_callback __attribute__((noipa))
+get_callback ()
+{
+  return cb1;
+}
+
+static void
+f (int c, int l, silly_callback p)
+{
+  int i;
+
+  for (i = 0; i < c; i++)
+    array[i] = 455;
+
+  for (i = 0; i < 200; i++)
+    {
+      p (l);
+      if (obscured_one ())
+       break;
+    }
+
+  if (l > 0)
+    f (c * 2, l - 1, p);
+  blah = l;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int i;
+  for (i = 0; i < 1000; i++)
+    {
+      f (0, 5, get_callback ());
+      if (v != 25)
+       __builtin_abort ();
+      if (obscured_one ())
+       break;
+    }
+
+  for (i = 0; i < 1000; i++)
+    {
+      f (obscured_zero (), obscured_two (), cb2);
+      if (v != 125)
+       __builtin_abort ();
+      if (obscured_one ())
+       break;
+    }
+
+  return 0;
+}