aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-09-24 15:10:04 +0200
committerJan Hubicka <jh@suse.cz>2020-09-24 15:10:04 +0200
commit9de8fa8052154a83b82f8b3785ec100d8cb24261 (patch)
tree04b98e665a3d3cd769b80f439feca5fe86295ffa /gcc
parentc33f474239308d81bf96cfdb2520d25488ad8724 (diff)
downloadgcc-9de8fa8052154a83b82f8b3785ec100d8cb24261.zip
gcc-9de8fa8052154a83b82f8b3785ec100d8cb24261.tar.gz
gcc-9de8fa8052154a83b82f8b3785ec100d8cb24261.tar.bz2
Add modref testcase
* gcc.dg/tree-ssa/modref-1.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/modref-1.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-1.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-1.c
new file mode 100644
index 0000000..a80ca6b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-1.c
@@ -0,0 +1,45 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+int p,q,r,s,*ptr=&q, *ptr2=&p;
+__attribute__ ((noinline))
+int
+test (int *p)
+{
+ *p = 1;
+}
+int
+test1()
+{
+ q = 123;
+ test(&p);
+ return q;
+}
+int
+test2()
+{
+ int *ptr = p ? &q : &s;
+ *ptr = 124;
+ test(&p);
+ return *ptr;
+}
+int
+test3()
+{
+ int *ptr = p ? &p : &s;
+ q = 125;
+ test(ptr);
+ return q;
+}
+int
+test4()
+{
+ int *ptr1 = p ? &q : &s;
+ int *ptr = p ? &r : &p;
+ *ptr1 = 126;
+ test(ptr);
+ return *ptr1;
+}
+/* { dg-final { scan-tree-dump "return 123" "optimized"} } */
+/* { dg-final { scan-tree-dump "return 124" "optimized"} } */
+/* { dg-final { scan-tree-dump "return 125" "optimized"} } */
+/* { dg-final { scan-tree-dump "return 126" "optimized"} } */