Debian Codegraph @

gcc/testsuite/gcc.target/avr/pr122222-sitod.c

raw
1 /* { dg-do run { target { ! avr_tiny } } } */
2 /* { dg-additional-options { -std=gnu99 -Os -mcall-prologues } } */
3
4 #if __SIZEOF_LONG_DOUBLE__ == 8
5
6 typedef long double D;
7 typedef __INT32_TYPE__ int32_t;
8 typedef __UINT32_TYPE__ uint32_t;
9 typedef __UINT8_TYPE__ uint8_t;
10
11 #define ARRAY_SIZE(X) (sizeof(X) / sizeof(*X))
12
13 void testu (void)
14 {
15 static const volatile __flash uint32_t vals[] =
16 {
17 0, 1ul, -1ul, (-1ul) << 1,
18 1ul << 31, 1ul << 30, 1ul << 29, 1ul << 28, 1ul << 27, 1ul << 26,
19 1ul << 25, 1ul << 24, 0xff, 123456789
20 };
21
22 for (uint8_t i = 0; i < ARRAY_SIZE (vals); ++i)
23 {
24 D x = (D) vals[i];
25 __asm ("" : "+r" (x));
26 if ((uint32_t) x != vals[i])
27 __builtin_exit (__LINE__);
28 }
29 }
30
31 void tests (void)
32 {
33 static const volatile __flash int32_t vals[] =
34 {
35 0, 1L, -1L, 0x7fffffff, -0x7fffffff, -0x7fffffff - 1,
36 -123456789
37 };
38
39 for (uint8_t i = 0; i < ARRAY_SIZE (vals); ++i)
40 {
41 D x = (D) vals[i];
42 __asm ("" : "+r" (x));
43 if ((int32_t) x != vals[i])
44 __builtin_exit (__LINE__);
45 }
46 }
47
48 int main (void)
49 {
50 testu ();
51 tests ();
52
53 return 0;
54 }
55 #else
56 int main (void)
57 {
58 return 0;
59 }
60 #endif