Add modref testcases
authorJan Hubicka <jh@suse.cz>
Sat, 26 Sep 2020 08:44:53 +0000 (10:44 +0200)
committerJan Hubicka <jh@suse.cz>
Sat, 26 Sep 2020 08:44:53 +0000 (10:44 +0200)
gcc/testsuite/

* gcc.dg/lto/modref-1_0.c: New test.
* gcc.dg/lto/modref-1_1.c: New test.
* gcc.dg/tree-ssa/modref-2.c: New test.

gcc/testsuite/gcc.dg/lto/modref-1_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/modref-1_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/modref-2.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/lto/modref-1_0.c b/gcc/testsuite/gcc.dg/lto/modref-1_0.c
new file mode 100644 (file)
index 0000000..8fcb9ec
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options {"-O2 -flto-partition=max -flto"}  } */
+extern void recursive (int *a, int *b, int *c, int level);
+int
+main()
+{
+  int x = 123, y=124, z=125;
+  recursive (&x,&y,&z,1);
+  if (y)
+    __builtin_abort ();
+  if (!__builtin_constant_p (z))
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/modref-1_1.c b/gcc/testsuite/gcc.dg/lto/modref-1_1.c
new file mode 100644 (file)
index 0000000..c7c0eae
--- /dev/null
@@ -0,0 +1,13 @@
+short aa;
+void
+__attribute__ ((noinline, noclone))
+recursive (int *a, int *b, int *c, int level)
+{
+  if (level && c)
+    {
+      recursive (b,a,c,0);
+      aa++;
+    }
+  else
+    *a=0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-2.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-2.c
new file mode 100644 (file)
index 0000000..9999d37
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O2"  } */
+short aa;
+void
+__attribute__ ((noinline, noclone))
+recursive (int *a, int *b, int *c, int level)
+{
+  if (level && c)
+    {
+      recursive (b,a,c,0);
+      aa++;
+    }
+  else
+    *a=0;
+}
+int
+main()
+{
+  int x = 123, y=124, z=125;
+  recursive (&x,&y,&z,1);
+  if (y)
+    __builtin_abort ();
+  if (!__builtin_constant_p (z))
+    __builtin_abort ();
+  return 0;
+}