1 /* { dg-options "-funsafe-math-optimizations" } */
2 
3 double random_double (void);
4 int setjmp (void *);
5 void do_something (void);
6 
7 #define TEST_UNARY(FUNC)			\
8   double					\
9   FUNC##_dead (void *buffer)			\
10   {						\
11     double d = random_double ();		\
12     setjmp (buffer);				\
13     __builtin_##FUNC (d);			\
14     d += 1;					\
15     do_something ();				\
16     return d;					\
17   }						\
18 						\
19   double					\
20   FUNC##_live (void *buffer)			\
21   {						\
22     double d = random_double ();		\
23     setjmp (buffer);				\
24     d = __builtin_##FUNC (d);			\
25     do_something ();				\
26     return d;					\
27   }
28 
29 
30 #define TEST_BINARY(FUNC)			\
31   double					\
32   FUNC##_dead (void *buffer)			\
33   {						\
34     double d1 = random_double ();		\
35     double d2 = random_double ();		\
36     setjmp (buffer);				\
37     __builtin_##FUNC (d1, d2);			\
38     d1 += 1;					\
39     d2 += 1;					\
40     do_something ();				\
41     return d1 + d2;				\
42   }						\
43 						\
44   double					\
45   FUNC##_live (void *buffer)			\
46   {						\
47     double d1 = random_double ();		\
48     double d2 = random_double ();		\
49     setjmp (buffer);				\
50     d1 = __builtin_##FUNC (d1, d2);		\
51     d2 += 1;					\
52     return d1 + d2;				\
53   }
54 
55 TEST_UNARY (acos)
56 TEST_UNARY (asin)
57 TEST_UNARY (asinh)
58 TEST_UNARY (atan)
59 TEST_UNARY (atanh)
60 TEST_UNARY (cos)
61 TEST_UNARY (cosh)
62 TEST_UNARY (exp)
63 TEST_UNARY (expm1)
64 TEST_UNARY (exp2)
65 TEST_UNARY (exp10)
66 TEST_UNARY (log)
67 TEST_UNARY (log2)
68 TEST_UNARY (log10)
69 TEST_UNARY (log1p)
70 TEST_UNARY (significand)
71 TEST_UNARY (sin)
72 TEST_UNARY (sinh)
73 TEST_UNARY (sqrt)
74 
75 TEST_BINARY (fmod)
76 TEST_BINARY (remainder)
77