1 |
691 |
jeremybenn |
/* { dg-do run } */
|
2 |
|
|
/* { dg-options "-msim" } */
|
3 |
|
|
/* Note: The -msim above is actually there to override the default
|
4 |
|
|
options which include -ansi -pendantic and -Wlong-long... */
|
5 |
|
|
|
6 |
|
|
extern int printf (const char *, ...);
|
7 |
|
|
extern void exit (int);
|
8 |
|
|
extern void abort (void);
|
9 |
|
|
|
10 |
|
|
extern signed long _COM_CONVf32s (float);
|
11 |
|
|
extern unsigned long _COM_CONVf32u (float);
|
12 |
|
|
extern float _COM_CONV32sf (signed long);
|
13 |
|
|
extern float _COM_CONV32uf (unsigned long);
|
14 |
|
|
extern float _COM_ADDf (float, float);
|
15 |
|
|
extern float _COM_SUBf (float, float);
|
16 |
|
|
extern float _COM_MULf (float, float);
|
17 |
|
|
extern float _COM_DIVf (float, float);
|
18 |
|
|
extern int _COM_CMPLTf (float, float);
|
19 |
|
|
|
20 |
|
|
extern long long _COM_MUL64 (long long, long long);
|
21 |
|
|
extern signed long long _COM_DIV64s (long long, long long);
|
22 |
|
|
extern unsigned long long _COM_DIV64u (unsigned long long, unsigned long long);
|
23 |
|
|
extern long long _COM_SHLL64 (long long, int);
|
24 |
|
|
extern long long _COM_SHLR64 (long long, int);
|
25 |
|
|
extern long long _COM_SHAR64 (long long, int);
|
26 |
|
|
extern signed long long _COM_CONVf64s (float);
|
27 |
|
|
extern unsigned long long _COM_CONVf64u (float);
|
28 |
|
|
extern signed long long _COM_CONVd64s (double);
|
29 |
|
|
extern unsigned long long _COM_CONVd64u (double);
|
30 |
|
|
extern float _COM_CONV64sf (signed long long);
|
31 |
|
|
extern float _COM_CONV64uf (unsigned long long);
|
32 |
|
|
extern double _COM_CONV64sd (signed long long);
|
33 |
|
|
extern double _COM_CONV64ud (unsigned long long);
|
34 |
|
|
extern signed long long _COM_MOD64s (long long, long long);
|
35 |
|
|
extern unsigned long long _COM_MOD64u (unsigned long long, unsigned long long);
|
36 |
|
|
extern int _COM_CMPLT64s (long long, long long);
|
37 |
|
|
extern int _COM_CMPLT64u (unsigned long long, unsigned long long);
|
38 |
|
|
extern int _COM_CMPGT64s (long long, long long);
|
39 |
|
|
extern int _COM_CMPGT64u (unsigned long long, unsigned long long);
|
40 |
|
|
extern int _COM_CMPLE64s (long long, long long);
|
41 |
|
|
extern int _COM_CMPLE64u (unsigned long long, unsigned long long);
|
42 |
|
|
extern int _COM_CMPGE64s (long long, long long);
|
43 |
|
|
extern int _COM_CMPGE64u (unsigned long long, unsigned long long);
|
44 |
|
|
extern int _COM_CMPEQ64 (long long, long long);
|
45 |
|
|
extern int _COM_CMPNE64 (long long, long long);
|
46 |
|
|
|
47 |
|
|
extern double _COM_ADDd (double, double);
|
48 |
|
|
extern double _COM_SUBd (double, double);
|
49 |
|
|
extern double _COM_MULd (double, double);
|
50 |
|
|
extern double _COM_DIVd (double, double);
|
51 |
|
|
extern signed long _COM_CONVd32s (double);
|
52 |
|
|
extern unsigned long _COM_CONVd32u (double);
|
53 |
|
|
extern double _COM_CONV32sd (signed long);
|
54 |
|
|
extern double _COM_CONV32ud (unsigned long);
|
55 |
|
|
extern double _COM_CONVfd (float);
|
56 |
|
|
extern float _COM_CONVdf (double);
|
57 |
|
|
extern double _COM_NEGd (double);
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
/* #define DEBUG 1 */
|
61 |
|
|
|
62 |
|
|
#ifdef DEBUG
|
63 |
|
|
# define TEST1(func,arg1,result) if (func (arg1) != result) printf ("fail: " #func " (" #arg1 ") returns %x rather than " #result "\n", func (arg1))
|
64 |
|
|
# define TEST2(func,arg1,arg2,result) if (func (arg1, arg2) != result) printf ("fail: " #func " (" #arg1 ", " #arg2 ") returns %x rather than " #result "\n", func (arg1, arg2))
|
65 |
|
|
# define TEST_CMP(func, low_arg, high_arg, lt_result, eq_result, gt_result) \
|
66 |
|
|
do \
|
67 |
|
|
{ \
|
68 |
|
|
int res; \
|
69 |
|
|
\
|
70 |
|
|
if ((res = func (low_arg, high_arg)) != lt_result) printf ("fail: " #func " (" #low_arg ", " #high_arg ") returns %d rather than %d\n", res, lt_result); \
|
71 |
|
|
if ((res = func (high_arg, low_arg)) != gt_result) printf ("fail: " #func " (" #high_arg ", " #low_arg ") returns %d rather than %d\n", res, gt_result); \
|
72 |
|
|
if ((res = func (low_arg, low_arg)) != eq_result) printf ("fail: " #func " (" #low_arg ", " #low_arg ") returns %d rather than %d\n", res, eq_result); \
|
73 |
|
|
} \
|
74 |
|
|
while (0)
|
75 |
|
|
#else
|
76 |
|
|
# define TEST1(func,arg1,result) if (func (arg1) != result) abort ()
|
77 |
|
|
# define TEST2(func,arg1,arg2,result) if (func (arg1, arg2) != result) abort ()
|
78 |
|
|
# define TEST_CMP(func,low,high,lt_res,eq_res,gt_res) \
|
79 |
|
|
if ( (func (low, high) != lt_res) \
|
80 |
|
|
|| (func (high, low) != gt_res) \
|
81 |
|
|
|| (func (low, low) != eq_res)) \
|
82 |
|
|
abort ();
|
83 |
|
|
#endif
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
int
|
87 |
|
|
main (void)
|
88 |
|
|
{
|
89 |
|
|
#ifdef DEBUG
|
90 |
|
|
printf ("Tests starting\n");
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
TEST1 (_COM_CONVf32s, -2.0f, -2);
|
94 |
|
|
TEST1 (_COM_CONVf32u, -2.0f, (unsigned) -2);
|
95 |
|
|
TEST1 (_COM_CONV32sf, -2, -2.0f);
|
96 |
|
|
TEST1 (_COM_CONV32uf, 2, 2.0f);
|
97 |
|
|
TEST2 (_COM_ADDf, 1.0f, 2.0f, 3.0f);
|
98 |
|
|
TEST2 (_COM_SUBf, 3.0f, 2.0f, 1.0f);
|
99 |
|
|
TEST2 (_COM_MULf, 2.0f, 3.0f, 6.0f);
|
100 |
|
|
TEST2 (_COM_DIVf, 6.0f, 2.0f, 3.0f);
|
101 |
|
|
TEST_CMP (_COM_CMPLTf, 1.0f, 2.0f, 1, 0, 0);
|
102 |
|
|
TEST_CMP (_COM_CMPGTf, 1.0f, 2.0f, 0, 0, 1);
|
103 |
|
|
TEST_CMP (_COM_CMPLEf, 1.0f, 2.0f, 1, 1, 0);
|
104 |
|
|
TEST_CMP (_COM_CMPGEf, 1.0f, 2.0f, 0, 1, 1);
|
105 |
|
|
TEST_CMP (_COM_CMPEQf, 1.0f, 2.0f, 0, 1, 0);
|
106 |
|
|
TEST_CMP (_COM_CMPNEf, 1.0f, 2.0f, 1, 0, 1);
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
TEST2 (_COM_MUL64, 2LL, 4LL, 8LL);
|
110 |
|
|
TEST2 (_COM_DIV64s, 6LL, 3LL, 2LL);
|
111 |
|
|
TEST2 (_COM_DIV64u, 6ULL, 3ULL, 2ULL);
|
112 |
|
|
TEST2 (_COM_SHLL64, 6LL, 3, 48LL);
|
113 |
|
|
TEST2 (_COM_SHLR64, 8LL, 2, 2LL);
|
114 |
|
|
TEST2 (_COM_SHAR64, -1LL, 2, -1LL);
|
115 |
|
|
TEST1 (_COM_CONVf64s, -2.0f, -2LL);
|
116 |
|
|
TEST1 (_COM_CONVf64u, 2.0f, 2ULL);
|
117 |
|
|
TEST1 (_COM_CONVd64s, -2.0, -2LL);
|
118 |
|
|
TEST1 (_COM_CONVd64u, 2.0, 2ULL);
|
119 |
|
|
TEST1 (_COM_CONV64sf, -2LL, -2.0f);
|
120 |
|
|
TEST1 (_COM_CONV64uf, 2ULL, 2.0f);
|
121 |
|
|
TEST1 (_COM_CONV64sd, -2LL, -2.0);
|
122 |
|
|
TEST1 (_COM_CONV64ud, 2ULL, 2.0);
|
123 |
|
|
TEST2 (_COM_MOD64s, 4LL, 3LL, 1LL);
|
124 |
|
|
TEST2 (_COM_MOD64u, 4ULL, 3ULL, 1ULL);
|
125 |
|
|
TEST_CMP (_COM_CMPLT64s, 1LL, 2LL, 1, 0, 0);
|
126 |
|
|
TEST_CMP (_COM_CMPLT64u, 1ULL, 2ULL, 1, 0, 0);
|
127 |
|
|
TEST_CMP (_COM_CMPGT64s, 1LL, 2LL, 0, 0, 1);
|
128 |
|
|
TEST_CMP (_COM_CMPGT64u, 1ULL, 2ULL, 0, 0, 1);
|
129 |
|
|
TEST_CMP (_COM_CMPLE64s, 1LL, 2LL, 1, 1, 0);
|
130 |
|
|
TEST_CMP (_COM_CMPLE64u, 1ULL, 2ULL, 1, 1, 0);
|
131 |
|
|
TEST_CMP (_COM_CMPGE64s, 1LL, 2LL, 0, 1, 1);
|
132 |
|
|
TEST_CMP (_COM_CMPGE64u, 1ULL, 2ULL, 0, 1, 1);
|
133 |
|
|
TEST_CMP (_COM_CMPEQ64, 1LL, 2LL, 0, 1, 0);
|
134 |
|
|
TEST_CMP (_COM_CMPNE64, 1LL, 2LL, 1, 0, 1);
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
TEST2 (_COM_ADDd, 1.0, 2.0, 3.0);
|
138 |
|
|
TEST2 (_COM_SUBd, 3.0, 2.0, 1.0);
|
139 |
|
|
TEST2 (_COM_MULd, 2.0, 3.0, 6.0);
|
140 |
|
|
TEST2 (_COM_DIVd, 6.0, 2.0, 3.0);
|
141 |
|
|
TEST1 (_COM_CONVd32s, -2.0, -2);
|
142 |
|
|
TEST1 (_COM_CONVd32u, -2.0, (unsigned) -2);
|
143 |
|
|
TEST1 (_COM_CONV32sd, -2, -2.0);
|
144 |
|
|
TEST1 (_COM_CONV32ud, 2, 2.0);
|
145 |
|
|
TEST1 (_COM_CONVfd, 2.0f, 2.0);
|
146 |
|
|
TEST1 (_COM_CONVdf, 2.0, 2.0f);
|
147 |
|
|
TEST1 (_COM_NEGd, -2.0, 2.0);
|
148 |
|
|
TEST_CMP (_COM_CMPLTd, 1.0, 2.0, 1, 0, 0);
|
149 |
|
|
TEST_CMP (_COM_CMPGTd, 1.0, 2.0, 0, 0, 1);
|
150 |
|
|
TEST_CMP (_COM_CMPLEd, 1.0, 2.0, 1, 1, 0);
|
151 |
|
|
TEST_CMP (_COM_CMPGEd, 1.0, 2.0, 0, 1, 1);
|
152 |
|
|
TEST_CMP (_COM_CMPEQd, 1.0, 2.0, 0, 1, 0);
|
153 |
|
|
TEST_CMP (_COM_CMPNEd, 1.0, 2.0, 1, 0, 1);
|
154 |
|
|
|
155 |
|
|
#ifdef DEBUG
|
156 |
|
|
printf ("Tests finished\n");
|
157 |
|
|
#endif
|
158 |
|
|
exit (0);
|
159 |
|
|
}
|