OSDN Git Service

PR tree-optimization/52019
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / guality / sra-1.c
1 /* PR debug/43983 */
2 /* { dg-do run } */
3 /* { dg-options "-g" } */
4
5 struct A { int i; int j; };
6 struct B { int : 4; int i : 12; int j : 12; int : 4; };
7
8 __attribute__((noinline)) void
9 bar (int x)
10 {
11   asm volatile ("" : : "r" (x) : "memory");
12 }
13
14 __attribute__((noinline)) int
15 f1 (int k)
16 {
17   struct A a = { 4, k + 6 };
18   asm ("" : "+r" (a.i));
19   a.j++;
20   bar (a.i);            /* { dg-final { gdb-test 21 "a.i" "4" } } */
21   bar (a.j);            /* { dg-final { gdb-test 21 "a.j" "14" } } */
22   return a.i + a.j;
23 }
24
25 __attribute__((noinline)) int
26 f2 (int k)
27 {
28   int a[2] = { 4, k + 6 };
29   asm ("" : "+r" (a[0]));
30   a[1]++;
31   bar (a[0]);           /* { dg-final { gdb-test 32 "a\[0\]" "4" } } */
32   bar (a[1]);           /* { dg-final { gdb-test 32 "a\[1\]" "14" } } */
33   return a[0] + a[1];
34 }
35
36 __attribute__((noinline)) int
37 f3 (int k)
38 {
39   struct B a = { 4, k + 6 };
40   asm ("" : "+r" (a.i));
41   a.j++;
42   bar (a.i);            /* { dg-final { gdb-test 43 "a.i" "4" } } */
43   bar (a.j);            /* { dg-final { gdb-test 43 "a.j" "14" } } */
44   return a.i + a.j;
45 }
46
47 int
48 main (void)
49 {
50   int k;
51   asm ("" : "=r" (k) : "0" (7));
52   f1 (k);
53   f2 (k);
54   f3 (k);
55   return 0;
56 }