re PR tree-optimization/33291 (a+=2; a+=2 not simplified to a+=4; with -O3 ...
[gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-ccp-9.c
1 /* { dg-do compile } */
2 /* { dg-options "-O1 -fdump-tree-optimized" } */
3
4 /* Check that cprop works for assignments to array elements and structs. */
5
6 struct foo {
7 int a;
8 };
9
10 extern void link_error (void);
11
12 void
13 test9 (struct foo f)
14 {
15 f.a = 0;
16 if (f.a != 0)
17 link_error ();
18 }
19
20 void
21 test99 (struct foo *f)
22 {
23 f->a = 0;
24 if (f->a != 0)
25 link_error ();
26 }
27
28 void
29 test999 (int *arr)
30 {
31 *arr = 0;
32 if (*arr != 0)
33 link_error ();
34 }
35
36 void
37 test9999 (int *arr)
38 {
39 arr[13] = 0;
40 if (arr[13] != 0)
41 link_error ();
42 }
43
44 void
45 test99999 (int *arr, int j)
46 {
47 arr[j] = 0;
48 if (arr[j] != 0)
49 link_error ();
50 }
51
52 /* There should be no link_error calls, if there is any, the
53 optimization has failed */
54 /* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
55 /* { dg-final { cleanup-tree-dump "optimized" } } */