PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / fold-cstring.c
blobf92b120b3b7620fbba7670fa7c7c108f9d65a665
1 /* { dg-do run } */
2 /* { dg-options "-O" } */
4 /* The following are testcases for native_interpret_int,
5 native_interpret_complex and native_interpret_vector decoding
6 pieces of a string constant encoded by native_encode_string. */
8 extern void abort (void);
10 /* We should fold all reads from xconstant and eliminate it, removing
11 the reference to blah which cannot be resolved at link time. */
12 extern int blah;
14 static const struct {
15 int *y;
16 const char x[32] __attribute__((aligned(32)));
17 } xconstant = { &blah, "01234567899876543210123456789000" };
19 typedef int v4si __attribute__((vector_size(16)));
21 int main()
23 if (sizeof (int) != 4)
24 return 0;
25 if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
27 if (*(int *)&xconstant.x[4] != 0x34353637)
28 abort ();
29 if ((*(v4si *)&xconstant.x[16])[1] != 0x31323334)
30 abort ();
31 if (__imag (*(_Complex int *)&xconstant.x[8]) != 0x37363534)
32 abort ();
34 else if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
36 if (*(int *)&xconstant.x[4] != 0x37363534)
37 abort ();
38 if ((*(v4si *)&xconstant.x[16])[1] != 0x34333231)
39 abort ();
40 if (__imag (*(_Complex int *)&xconstant.x[8]) != 0x34353637)
41 abort ();
43 return 0;