Debian Codegraph @

gcc/testsuite/gcc.dg/sso/ipa-sra-1.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fipa-sra" } */
3
4
5 struct __attribute__((scalar_storage_order("little-endian"))) LE
6 {
7 int i;
8 int j;
9 };
10
11 struct __attribute__((scalar_storage_order("big-endian"))) BE
12 {
13 int i;
14 int j;
15 };
16
17 struct LE gle;
18 struct BE gbe;
19
20 #define VAL 0x12345678
21
22 void __attribute__((noipa))
23 fill (void)
24 {
25 gle.i = VAL;
26 gle.j = 0xdeadbeef;
27 gbe.i = VAL;
28 gbe.j = 0x11223344;
29 }
30
31 static int __attribute__((noinline))
32 readLE (struct LE p)
33 {
34 return p.i;
35 }
36
37 static int __attribute__((noinline))
38 readBE (struct BE p)
39 {
40 return p.i;
41 }
42
43 int
44 main (int argc, char *argv[])
45 {
46 int r;
47 fill ();
48
49 r = readLE (gle);
50 if (r != VAL)
51 __builtin_abort ();
52 r = readBE (gbe);
53 if (r != VAL)
54 __builtin_abort ();
55
56 return 0;
57 }