aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/modref-1.c
blob: a80ca6b67c41fdeaab4b6a8f50f7b9275d37b781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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"} } */