summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-3.c
blob: 86a706b80ef709684f483574ec91f0ba085538bc (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-ccp2" } */

extern void link_error (void);

/* Some addresses clearly cannot be equal, check that some address
   expressions can be evaluated as constants.
   Most of the tests are folding tests, but at least some require
   points-to analysis, so we scan the first CCP dump after PTA.  */

char g1, g2;
void test6 (char p1, char p2)
{
  char l1 = 1, l2 = 2;
  static char s1 = 5, s2 = 7;
  if (&l1 == &l2)
    link_error ();

  if (&p1 == &p2)
    link_error ();

  if (&s1 == &s2)
    link_error ();

  if (&g1 == &g2)
    link_error ();
  
  if (&p1 == &l1)
    link_error (); 

  if (&p1 == &s1)
    link_error (); 

  if (&p1 == &l2)
    link_error (); 

  if (&p1 == &g1)
    link_error (); 

  if (&l1 == &g1)
    link_error (); 

  if (&s1 == &g1)
    link_error (); 
}

extern void *alloc (int) __attribute__ ((malloc));
char gca1[128];
char* __restrict__ rgc1;
char* test66 (char * __restrict__ rp1, char * __restrict__ rp2, char *p1)
{
  char * __restrict__ rl1 = p1;
  char * l1 = (char*) alloc (20);

  if (l1 == rgc1)
    link_error ();

  if (l1 == rp1)
    link_error ();

  if (l1 == rl1)
    link_error ();

  if (l1 == gca1)
    link_error ();

  if (rl1 == rgc1)
    link_error ();

  if (rl1 == rp1)
    link_error ();

  if (rl1 == gca1)
    link_error ();
  
  if (rp1 == rp2)
    link_error ();

  if (rp1 == rgc1)
    link_error ();
  
  if (rp1 == gca1)
    link_error ();

  if (gca1 == rgc1)
    link_error ();

}

int gci1[128];
int* __restrict__ rgi1;
int* test666 (int * __restrict__ rp1, int * __restrict__ rp2, int *p1)
{
  int * __restrict__ rl1 = p1;
  int * l1 = (int*) alloc (20);

  if (l1 == rgi1)
    link_error ();

  if (l1 == rp1)
    link_error ();

  if (l1 == rl1)
    link_error ();

  if (l1 == gci1)
    link_error ();

  if (rl1 == rgi1)
    link_error ();

  if (rl1 == rp1)
    link_error ();

  if (rl1 == gci1)
    link_error ();
  
  if (rp1 == rp2)
    link_error ();

  if (rp1 == rgi1)
    link_error ();
  
  if (rp1 == gci1)
    link_error ();

  if (gci1 == rgi1)
    link_error ();
}


/* There should be not link_error calls, if there is any the
   optimization has failed */
/* ??? While we indeed don't handle some of these, a couple of the
   restrict tests are incorrect.  */
/* { dg-final { scan-tree-dump-times "link_error" 0 "ccp2" { xfail *-*-* } } } */
/* { dg-final { cleanup-tree-dump "ccp2" } } */