Add gcc.dg/tree-ssa/modref-3.c testcase
authorJan Hubicka <jh@suse.cz>
Sat, 3 Oct 2020 15:20:54 +0000 (17:20 +0200)
committerJan Hubicka <jh@suse.cz>
Sat, 3 Oct 2020 15:20:54 +0000 (17:20 +0200)
* gcc.dg/tree-ssa/modref-3.c: New test.

gcc/testsuite/gcc.dg/tree-ssa/modref-3.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-3.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-3.c
new file mode 100644 (file)
index 0000000..668c6c2
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized"  } */
+struct a
+{
+  int b;
+  int c;
+};
+
+__attribute__ ((noclone, noinline))
+void
+test (struct a *a)
+{
+  a->b = 2;
+}
+int
+foo ()
+{
+  struct a a = {113,114};
+  test (&a);
+  return a.c;
+}
+int
+foo2 (struct a *a)
+{
+  a->b = 123;
+  a->c = 124;
+  test (a);
+  return a->c;
+}
+/* { dg-final { scan-tree-dump "return 114" "optimized"} } */
+/* { dg-final { scan-tree-dump "return 124" "optimized"} } */