2 /* { dg-options "-std=gnu99 -fwrapv" } */
6 extern void abort (void);
7 extern void exit (int);
10 typedef _Sat _Fract satfx_t
;
13 SS_FUN (ss_add
, +, fx_t
, r
)
14 SS_FUN (ss_sub
, -, fx_t
, r
)
17 __attribute__((noinline,noclone)) \
18 satfx_t ss_add2_##N (satfx_t a) \
20 return ss_add_r (a, X##P##-##15r); \
22 __attribute__((noinline,noclone)) \
23 satfx_t ss_add_##N (satfx_t a) \
25 return a + X##P##-##15r; \
27 __attribute__((noinline,noclone)) \
28 satfx_t ss_sub2_##N (satfx_t a) \
30 return ss_sub_r (a, X##P##-##15r); \
32 __attribute__((noinline,noclone)) \
33 satfx_t ss_sub_##N (satfx_t a) \
35 return a - X##P##-##15r; \
40 __attribute__((noinline
,noclone
))
41 satfx_t
ss_add2_99 (satfx_t a
)
43 return ss_add_r (a
, __FRACT_MIN__
);
46 __attribute__((noinline
,noclone
))
47 satfx_t
ss_add_99 (satfx_t a
)
49 return a
+ __FRACT_MIN__
;
52 __attribute__((noinline
,noclone
))
53 satfx_t
ss_sub2_99 (satfx_t a
)
55 return ss_sub_r (a
, __FRACT_MIN__
);
58 __attribute__((noinline
,noclone
))
59 satfx_t
ss_sub_99 (satfx_t a
)
61 return a
- __FRACT_MIN__
;
65 satfx_t (* __flash
const fun
[])(satfx_t
) =
68 ss_add_##N, ss_add2_##N, \
69 ss_sub_##N, ss_sub2_##N,
76 const volatile __flash intfx_t vals
[] =
78 0, -1, 1, -2, 2, -127, -128, -129,
79 0x7f, 0x80, 0x81, 0x100,
80 0x4000, 0x3e80, 0x3f80,
82 0x7f7f, 0x7f81, 0x7f80,
84 0x8000, 0x8001, 0x8080,
85 0x8081, 0x80ff, 0x80fe,
86 0x8100, 0x8180, 0x817f,
87 0xff00, 0xff01, 0xff01,
93 for (unsigned int i
= 0; i
< sizeof (vals
) / sizeof (*vals
); i
++)
96 intfx_t val
= vals
[i
];
97 __builtin_memcpy (&a
, &val
, sizeof (satfx_t
));
98 for (unsigned int f
= 0; f
< sizeof (fun
) / sizeof (*fun
); f
+= 2)
100 if (fun
[f
](a
) != fun
[f
+1](a
))