xref: /openbmc/qemu/tests/tcg/hexagon/usr.c (revision 1f2146f7)
1 /*
2  *  Copyright(c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * Test instructions that might set bits in user status register (USR)
20  */
21 
22 #include <stdio.h>
23 #include <stdint.h>
24 
25 int err;
26 
27 #include "hex_test.h"
28 
29 /*
30  * Some of the instructions tested are only available on certain versions
31  * of the Hexagon core
32  */
33 #define CORE_HAS_AUDIO    (__HEXAGON_ARCH__ >= 67 && defined(__HEXAGON_AUDIO__))
34 #define CORE_IS_V67       (__HEXAGON_ARCH__ >= 67)
35 
36 /*
37  * Templates for functions to execute an instruction
38  *
39  * The templates vary by the number of arguments and the types of the args
40  * and result.  We use one letter in the macro name for the result and each
41  * argument:
42  *     x             unknown (specified in a subsequent template) or don't care
43  *     R             register (32 bits)
44  *     P             pair (64 bits)
45  *     p             predicate
46  *     I             immediate
47  *     Xx            read/write
48  */
49 
50 /* Template for instructions with one register operand */
51 #define FUNC_x_OP_x(RESTYPE, SRCTYPE, NAME, INSN) \
52 static RESTYPE NAME(SRCTYPE src, uint32_t *usr_result) \
53 { \
54     RESTYPE result; \
55     uint32_t usr; \
56     asm(CLEAR_USRBITS \
57         INSN  "\n\t" \
58         "%1 = usr\n\t" \
59         : "=r"(result), "=r"(usr) \
60         : "r"(src) \
61         : "r2", "usr"); \
62       *usr_result = usr & 0x3f; \
63       return result; \
64 }
65 
66 #define FUNC_R_OP_R(NAME, INSN) \
67 FUNC_x_OP_x(uint32_t, uint32_t, NAME, INSN)
68 
69 #define FUNC_R_OP_P(NAME, INSN) \
70 FUNC_x_OP_x(uint32_t, uint64_t, NAME, INSN)
71 
72 #define FUNC_P_OP_P(NAME, INSN) \
73 FUNC_x_OP_x(uint64_t, uint64_t, NAME, INSN)
74 
75 #define FUNC_P_OP_R(NAME, INSN) \
76 FUNC_x_OP_x(uint64_t, uint32_t, NAME, INSN)
77 
78 /*
79  * Template for instructions with a register and predicate result
80  * and one register operand
81  */
82 #define FUNC_xp_OP_x(RESTYPE, SRCTYPE, NAME, INSN) \
83 static RESTYPE NAME(SRCTYPE src, uint8_t *pred_result, uint32_t *usr_result) \
84 { \
85     RESTYPE result; \
86     uint8_t pred; \
87     uint32_t usr; \
88     asm(CLEAR_USRBITS \
89         INSN  "\n\t" \
90         "%1 = p2\n\t" \
91         "%2 = usr\n\t" \
92         : "=r"(result), "=r"(pred), "=r"(usr) \
93         : "r"(src) \
94         : "r2", "p2", "usr"); \
95     *pred_result = pred; \
96     *usr_result = usr & 0x3f; \
97     return result; \
98 }
99 
100 #define FUNC_Rp_OP_R(NAME, INSN) \
101 FUNC_xp_OP_x(uint32_t, uint32_t, NAME, INSN)
102 
103 /* Template for instructions with two register operands */
104 #define FUNC_x_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \
105 static RESTYPE NAME(SRC1TYPE src1, SRC2TYPE src2, uint32_t *usr_result) \
106 { \
107     RESTYPE result; \
108     uint32_t usr; \
109     asm(CLEAR_USRBITS \
110         INSN "\n\t" \
111         "%1 = usr\n\t" \
112         : "=r"(result), "=r"(usr) \
113         : "r"(src1), "r"(src2) \
114         : "r2", "usr"); \
115     *usr_result = usr & 0x3f; \
116     return result; \
117 }
118 
119 #define FUNC_P_OP_PP(NAME, INSN) \
120 FUNC_x_OP_xx(uint64_t, uint64_t, uint64_t, NAME, INSN)
121 
122 #define FUNC_R_OP_PP(NAME, INSN) \
123 FUNC_x_OP_xx(uint32_t, uint64_t, uint64_t, NAME, INSN)
124 
125 #define FUNC_P_OP_RR(NAME, INSN) \
126 FUNC_x_OP_xx(uint64_t, uint32_t, uint32_t, NAME, INSN)
127 
128 #define FUNC_R_OP_RR(NAME, INSN) \
129 FUNC_x_OP_xx(uint32_t, uint32_t, uint32_t, NAME, INSN)
130 
131 #define FUNC_R_OP_PR(NAME, INSN) \
132 FUNC_x_OP_xx(uint32_t, uint64_t, uint32_t, NAME, INSN)
133 
134 #define FUNC_P_OP_PR(NAME, INSN) \
135 FUNC_x_OP_xx(uint64_t, uint64_t, uint32_t, NAME, INSN)
136 
137 /*
138  * Template for instructions with a register and predicate result
139  * and two register operands
140  */
141 #define FUNC_xp_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \
142 static RESTYPE NAME(SRC1TYPE src1, SRC2TYPE src2, \
143                     uint8_t *pred_result, uint32_t *usr_result) \
144 { \
145     RESTYPE result; \
146     uint8_t pred; \
147     uint32_t usr; \
148     asm(CLEAR_USRBITS \
149         INSN  "\n\t" \
150         "%1 = p2\n\t" \
151         "%2 = usr\n\t" \
152         : "=r"(result), "=r"(pred), "=r"(usr) \
153         : "r"(src1), "r"(src2) \
154         : "r2", "p2", "usr"); \
155     *pred_result = pred; \
156     *usr_result = usr & 0x3f; \
157     return result; \
158 }
159 
160 #define FUNC_Rp_OP_RR(NAME, INSN) \
161 FUNC_xp_OP_xx(uint32_t, uint32_t, uint32_t, NAME, INSN)
162 
163 /* Template for instructions with one register and one immediate */
164 #define FUNC_x_OP_xI(RESTYPE, SRC1TYPE, NAME, INSN) \
165 static RESTYPE NAME(SRC1TYPE src1, int32_t src2, uint32_t *usr_result) \
166 { \
167     RESTYPE result; \
168     uint32_t usr; \
169     asm(CLEAR_USRBITS \
170         INSN "\n\t" \
171         "%1 = usr\n\t" \
172         : "=r"(result), "=r"(usr) \
173         : "r"(src1), "i"(src2) \
174         : "r2", "usr"); \
175     *usr_result = usr & 0x3f; \
176     return result; \
177 }
178 
179 #define FUNC_R_OP_RI(NAME, INSN) \
180 FUNC_x_OP_xI(uint32_t, uint32_t, NAME, INSN)
181 
182 #define FUNC_R_OP_PI(NAME, INSN) \
183 FUNC_x_OP_xI(uint32_t, uint64_t, NAME, INSN)
184 
185 /*
186  * Template for instructions with a read/write result
187  * and two register operands
188  */
189 #define FUNC_Xx_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \
190 static RESTYPE NAME(RESTYPE result, SRC1TYPE src1, SRC2TYPE src2, \
191                     uint32_t *usr_result) \
192 { \
193     uint32_t usr; \
194     asm(CLEAR_USRBITS \
195         INSN "\n\t" \
196         "%1 = usr\n\t" \
197         : "+r"(result), "=r"(usr) \
198         : "r"(src1), "r"(src2) \
199         : "r2", "usr"); \
200     *usr_result = usr & 0x3f; \
201     return result; \
202 }
203 
204 #define FUNC_XR_OP_RR(NAME, INSN) \
205 FUNC_Xx_OP_xx(uint32_t, uint32_t, uint32_t, NAME, INSN)
206 
207 #define FUNC_XP_OP_PP(NAME, INSN) \
208 FUNC_Xx_OP_xx(uint64_t, uint64_t, uint64_t, NAME, INSN)
209 
210 #define FUNC_XP_OP_RR(NAME, INSN) \
211 FUNC_Xx_OP_xx(uint64_t, uint32_t, uint32_t, NAME, INSN)
212 
213 /*
214  * Template for instructions with a read/write result
215  * and two register operands
216  */
217 #define FUNC_Xxp_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \
218 static RESTYPE NAME(RESTYPE result, SRC1TYPE src1, SRC2TYPE src2, \
219                     uint8_t *pred_result, uint32_t *usr_result) \
220 { \
221     uint32_t usr; \
222     uint8_t pred; \
223     asm(CLEAR_USRBITS \
224         INSN "\n\t" \
225         "%1 = p2\n\t" \
226         "%2 = usr\n\t" \
227         : "+r"(result), "=r"(pred), "=r"(usr) \
228         : "r"(src1), "r"(src2) \
229         : "r2", "usr"); \
230     *pred_result = pred; \
231     *usr_result = usr & 0x3f; \
232     return result; \
233 }
234 
235 #define FUNC_XPp_OP_PP(NAME, INSN) \
236 FUNC_Xxp_OP_xx(uint64_t, uint64_t, uint64_t, NAME, INSN)
237 
238 /*
239  * Template for instructions with a read/write result and
240  * two register and one predicate operands
241  */
242 #define FUNC_Xx_OP_xxp(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \
243 static RESTYPE NAME(RESTYPE result, SRC1TYPE src1, SRC2TYPE src2, uint8_t pred,\
244                     uint32_t *usr_result) \
245 { \
246     uint32_t usr; \
247     asm(CLEAR_USRBITS \
248         "p2 = %4\n\t" \
249         INSN "\n\t" \
250         "%1 = usr\n\t" \
251         : "+r"(result), "=r"(usr) \
252         : "r"(src1), "r"(src2), "r"(pred) \
253         : "r2", "p2", "usr"); \
254     *usr_result = usr & 0x3f; \
255     return result; \
256 }
257 
258 #define FUNC_XR_OP_RRp(NAME, INSN) \
259 FUNC_Xx_OP_xxp(uint32_t, uint32_t, uint32_t, NAME, INSN)
260 
261 /* Template for compare instructions with two register operands */
262 #define FUNC_CMP_xx(SRC1TYPE, SRC2TYPE, NAME, INSN) \
263 static uint32_t NAME(SRC1TYPE src1, SRC2TYPE src2, uint32_t *usr_result) \
264 { \
265     uint32_t result; \
266     uint32_t usr; \
267     asm(CLEAR_USRBITS \
268         INSN "\n\t" \
269         "%0 = p1\n\t" \
270         "%1 = usr\n\t" \
271         : "=r"(result), "=r"(usr) \
272         : "r"(src1), "r"(src2) \
273         : "p1", "r2", "usr"); \
274     *usr_result = usr & 0x3f; \
275     return result; \
276 }
277 
278 #define FUNC_CMP_RR(NAME, INSN) \
279 FUNC_CMP_xx(uint32_t, uint32_t, NAME, INSN)
280 
281 #define FUNC_CMP_PP(NAME, INSN) \
282 FUNC_CMP_xx(uint64_t, uint64_t, NAME, INSN)
283 
284 /*
285  * Function declarations using the templates
286  */
287 FUNC_R_OP_R(satub,              "%0 = satub(%2)")
288 FUNC_P_OP_PP(vaddubs,           "%0 = vaddub(%2, %3):sat")
289 FUNC_P_OP_PP(vadduhs,           "%0 = vadduh(%2, %3):sat")
290 FUNC_P_OP_PP(vsububs,           "%0 = vsubub(%2, %3):sat")
291 FUNC_P_OP_PP(vsubuhs,           "%0 = vsubuh(%2, %3):sat")
292 
293 /* Add vector of half integers with saturation and pack to unsigned bytes */
294 FUNC_R_OP_PP(vaddhubs,          "%0 = vaddhub(%2, %3):sat")
295 
296 /* Vector saturate half to unsigned byte */
297 FUNC_R_OP_P(vsathub,            "%0 = vsathub(%2)")
298 
299 /* Similar to above but takes a 32-bit argument */
300 FUNC_R_OP_R(svsathub,           "%0 = vsathub(%2)")
301 
302 /* Vector saturate word to unsigned half */
303 FUNC_P_OP_P(vsatwuh_nopack,     "%0 = vsatwuh(%2)")
304 
305 /* Similar to above but returns a 32-bit result */
306 FUNC_R_OP_P(vsatwuh,            "%0 = vsatwuh(%2)")
307 
308 /* Vector arithmetic shift halfwords with saturate and pack */
309 FUNC_R_OP_PI(asrhub_sat,        "%0 = vasrhub(%2, #%3):sat")
310 
311 /* Vector arithmetic shift halfwords with round, saturate and pack */
312 FUNC_R_OP_PI(asrhub_rnd_sat,    "%0 = vasrhub(%2, #%3):raw")
313 
314 FUNC_R_OP_RR(addsat,            "%0 = add(%2, %3):sat")
315 /* Similar to above but with register pairs */
316 FUNC_P_OP_PP(addpsat,           "%0 = add(%2, %3):sat")
317 
318 FUNC_XR_OP_RR(mpy_acc_sat_hh_s0, "%0 += mpy(%2.H, %3.H):sat")
319 FUNC_R_OP_RR(mpy_sat_hh_s1,     "%0 = mpy(%2.H, %3.H):<<1:sat")
320 FUNC_R_OP_RR(mpy_sat_rnd_hh_s1, "%0 = mpy(%2.H, %3.H):<<1:rnd:sat")
321 FUNC_R_OP_RR(mpy_up_s1_sat,     "%0 = mpy(%2, %3):<<1:sat")
322 FUNC_P_OP_RR(vmpy2s_s1,         "%0 = vmpyh(%2, %3):<<1:sat")
323 FUNC_P_OP_RR(vmpy2su_s1,        "%0 = vmpyhsu(%2, %3):<<1:sat")
324 FUNC_R_OP_RR(vmpy2s_s1pack,     "%0 = vmpyh(%2, %3):<<1:rnd:sat")
325 FUNC_P_OP_PP(vmpy2es_s1,        "%0 = vmpyeh(%2, %3):<<1:sat")
326 FUNC_R_OP_PP(vdmpyrs_s1,        "%0 = vdmpy(%2, %3):<<1:rnd:sat")
327 FUNC_XP_OP_PP(vdmacs_s0,        "%0 += vdmpy(%2, %3):sat")
328 FUNC_R_OP_RR(cmpyrs_s0,         "%0 = cmpy(%2, %3):rnd:sat")
329 FUNC_XP_OP_RR(cmacs_s0,         "%0 += cmpy(%2, %3):sat")
330 FUNC_XP_OP_RR(cnacs_s0,         "%0 -= cmpy(%2, %3):sat")
331 FUNC_P_OP_PP(vrcmpys_s1_h,      "%0 = vrcmpys(%2, %3):<<1:sat:raw:hi")
332 FUNC_XP_OP_PP(mmacls_s0,        "%0 += vmpyweh(%2, %3):sat")
333 FUNC_R_OP_RR(hmmpyl_rs1,        "%0 = mpy(%2, %3.L):<<1:rnd:sat")
334 FUNC_XP_OP_PP(mmaculs_s0,       "%0 += vmpyweuh(%2, %3):sat")
335 FUNC_R_OP_PR(cmpyi_wh,          "%0 = cmpyiwh(%2, %3):<<1:rnd:sat")
336 FUNC_P_OP_PP(vcmpy_s0_sat_i,    "%0 = vcmpyi(%2, %3):sat")
337 FUNC_P_OP_PR(vcrotate,          "%0 = vcrotate(%2, %3)")
338 FUNC_P_OP_PR(vcnegh,            "%0 = vcnegh(%2, %3)")
339 
340 #if CORE_HAS_AUDIO
341 FUNC_R_OP_PP(wcmpyrw,           "%0 = cmpyrw(%2, %3):<<1:sat")
342 #endif
343 
344 FUNC_R_OP_RR(addh_l16_sat_ll,   "%0 = add(%2.L, %3.L):sat")
345 FUNC_P_OP_P(vconj,              "%0 = vconj(%2):sat")
346 FUNC_P_OP_PP(vxaddsubw,         "%0 = vxaddsubw(%2, %3):sat")
347 FUNC_P_OP_P(vabshsat,           "%0 = vabsh(%2):sat")
348 FUNC_P_OP_PP(vnavgwr,           "%0 = vnavgw(%2, %3):rnd:sat")
349 FUNC_R_OP_RI(round_ri_sat,      "%0 = round(%2, #%3):sat")
350 FUNC_R_OP_RR(asr_r_r_sat,       "%0 = asr(%2, %3):sat")
351 FUNC_R_OP_RR(asl_r_r_sat,       "%0 = asl(%2, %3):sat")
352 
353 FUNC_XPp_OP_PP(ACS,             "%0, p2 = vacsh(%3, %4)")
354 
355 /* Floating point */
356 FUNC_R_OP_RR(sfmin,             "%0 = sfmin(%2, %3)")
357 FUNC_R_OP_RR(sfmax,             "%0 = sfmax(%2, %3)")
358 FUNC_R_OP_RR(sfadd,             "%0 = sfadd(%2, %3)")
359 FUNC_R_OP_RR(sfsub,             "%0 = sfsub(%2, %3)")
360 FUNC_R_OP_RR(sfmpy,             "%0 = sfmpy(%2, %3)")
361 FUNC_XR_OP_RR(sffma,            "%0 += sfmpy(%2, %3)")
362 FUNC_XR_OP_RR(sffms,            "%0 -= sfmpy(%2, %3)")
363 FUNC_CMP_RR(sfcmpuo,            "p1 = sfcmp.uo(%2, %3)")
364 FUNC_CMP_RR(sfcmpeq,            "p1 = sfcmp.eq(%2, %3)")
365 FUNC_CMP_RR(sfcmpgt,            "p1 = sfcmp.gt(%2, %3)")
366 FUNC_CMP_RR(sfcmpge,            "p1 = sfcmp.ge(%2, %3)")
367 
368 FUNC_P_OP_PP(dfadd,             "%0 = dfadd(%2, %3)")
369 FUNC_P_OP_PP(dfsub,             "%0 = dfsub(%2, %3)")
370 
371 #if CORE_IS_V67
372 FUNC_P_OP_PP(dfmin,             "%0 = dfmin(%2, %3)")
373 FUNC_P_OP_PP(dfmax,             "%0 = dfmax(%2, %3)")
374 FUNC_XP_OP_PP(dfmpyhh,          "%0 += dfmpyhh(%2, %3)")
375 #endif
376 
377 FUNC_CMP_PP(dfcmpuo,            "p1 = dfcmp.uo(%2, %3)")
378 FUNC_CMP_PP(dfcmpeq,            "p1 = dfcmp.eq(%2, %3)")
379 FUNC_CMP_PP(dfcmpgt,            "p1 = dfcmp.gt(%2, %3)")
380 FUNC_CMP_PP(dfcmpge,            "p1 = dfcmp.ge(%2, %3)")
381 
382 /* Conversions from sf */
383 FUNC_P_OP_R(conv_sf2df,         "%0 = convert_sf2df(%2)")
384 FUNC_R_OP_R(conv_sf2uw,         "%0 = convert_sf2uw(%2)")
385 FUNC_R_OP_R(conv_sf2w,          "%0 = convert_sf2w(%2)")
386 FUNC_P_OP_R(conv_sf2ud,         "%0 = convert_sf2ud(%2)")
387 FUNC_P_OP_R(conv_sf2d,          "%0 = convert_sf2d(%2)")
388 FUNC_R_OP_R(conv_sf2uw_chop,    "%0 = convert_sf2uw(%2):chop")
389 FUNC_R_OP_R(conv_sf2w_chop,     "%0 = convert_sf2w(%2):chop")
390 FUNC_P_OP_R(conv_sf2ud_chop,    "%0 = convert_sf2ud(%2):chop")
391 FUNC_P_OP_R(conv_sf2d_chop,     "%0 = convert_sf2d(%2):chop")
392 
393 /* Conversions from df */
394 FUNC_R_OP_P(conv_df2sf,         "%0 = convert_df2sf(%2)")
395 FUNC_R_OP_P(conv_df2uw,         "%0 = convert_df2uw(%2)")
396 FUNC_R_OP_P(conv_df2w,          "%0 = convert_df2w(%2)")
397 FUNC_P_OP_P(conv_df2ud,         "%0 = convert_df2ud(%2)")
398 FUNC_P_OP_P(conv_df2d,          "%0 = convert_df2d(%2)")
399 FUNC_R_OP_P(conv_df2uw_chop,    "%0 = convert_df2uw(%2):chop")
400 FUNC_R_OP_P(conv_df2w_chop,     "%0 = convert_df2w(%2):chop")
401 FUNC_P_OP_P(conv_df2ud_chop,    "%0 = convert_df2ud(%2):chop")
402 FUNC_P_OP_P(conv_df2d_chop,     "%0 = convert_df2d(%2):chop")
403 
404 /* Integer to float conversions */
405 FUNC_R_OP_R(conv_uw2sf,         "%0 = convert_uw2sf(%2)")
406 FUNC_R_OP_R(conv_w2sf,          "%0 = convert_w2sf(%2)")
407 FUNC_R_OP_P(conv_ud2sf,         "%0 = convert_ud2sf(%2)")
408 FUNC_R_OP_P(conv_d2sf,          "%0 = convert_d2sf(%2)")
409 
410 /* Special purpose floating point instructions */
411 FUNC_XR_OP_RRp(sffma_sc,        "%0 += sfmpy(%2, %3, p2):scale")
412 FUNC_Rp_OP_RR(sfrecipa,         "%0, p2 = sfrecipa(%3, %4)")
413 FUNC_R_OP_RR(sffixupn,          "%0 = sffixupn(%2, %3)")
414 FUNC_R_OP_RR(sffixupd,          "%0 = sffixupd(%2, %3)")
415 FUNC_R_OP_R(sffixupr,           "%0 = sffixupr(%2)")
416 FUNC_Rp_OP_R(sfinvsqrta,        "%0, p2 = sfinvsqrta(%3)")
417 
418 /*
419  * Templates for test cases
420  *
421  * Same naming convention as the function templates
422  */
423 #define TEST_x_OP_x(RESTYPE, CHECKFN, SRCTYPE, FUNC, SRC, RES, USR_RES) \
424     do { \
425         RESTYPE result; \
426         SRCTYPE src = SRC; \
427         uint32_t usr_result; \
428         result = FUNC(src, &usr_result); \
429         CHECKFN(result, RES); \
430         check32(usr_result, USR_RES); \
431     } while (0)
432 
433 #define TEST_R_OP_R(FUNC, SRC, RES, USR_RES) \
434 TEST_x_OP_x(uint32_t, check32, uint32_t, FUNC, SRC, RES, USR_RES)
435 
436 #define TEST_R_OP_P(FUNC, SRC, RES, USR_RES) \
437 TEST_x_OP_x(uint32_t, check32, uint64_t, FUNC, SRC, RES, USR_RES)
438 
439 #define TEST_P_OP_P(FUNC, SRC, RES, USR_RES) \
440 TEST_x_OP_x(uint64_t, check64, uint64_t, FUNC, SRC, RES, USR_RES)
441 
442 #define TEST_P_OP_R(FUNC, SRC, RES, USR_RES) \
443 TEST_x_OP_x(uint64_t, check64, uint32_t, FUNC, SRC, RES, USR_RES)
444 
445 #define TEST_xp_OP_x(RESTYPE, CHECKFN, SRCTYPE, FUNC, SRC, \
446                      RES, PRED_RES, USR_RES) \
447     do { \
448         RESTYPE result; \
449         SRCTYPE src = SRC; \
450         uint8_t pred_result; \
451         uint32_t usr_result; \
452         result = FUNC(src, &pred_result, &usr_result); \
453         CHECKFN(result, RES); \
454         check32(pred_result, PRED_RES); \
455         check32(usr_result, USR_RES); \
456     } while (0)
457 
458 #define TEST_Rp_OP_R(FUNC, SRC, RES, PRED_RES, USR_RES) \
459 TEST_xp_OP_x(uint32_t, check32, uint32_t, FUNC, SRC, RES, PRED_RES, USR_RES)
460 
461 #define TEST_x_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \
462                      FUNC, SRC1, SRC2, RES, USR_RES) \
463     do { \
464         RESTYPE result; \
465         SRC1TYPE src1 = SRC1; \
466         SRC2TYPE src2 = SRC2; \
467         uint32_t usr_result; \
468         result = FUNC(src1, src2, &usr_result); \
469         CHECKFN(result, RES); \
470         check32(usr_result, USR_RES); \
471     } while (0)
472 
473 #define TEST_P_OP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \
474 TEST_x_OP_xx(uint64_t, check64, uint64_t, uint64_t, \
475              FUNC, SRC1, SRC2, RES, USR_RES)
476 
477 #define TEST_R_OP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \
478 TEST_x_OP_xx(uint32_t, check32, uint64_t, uint64_t, \
479              FUNC, SRC1, SRC2, RES, USR_RES)
480 
481 #define TEST_P_OP_RR(FUNC, SRC1, SRC2, RES, USR_RES) \
482 TEST_x_OP_xx(uint64_t, check64, uint32_t, uint32_t, \
483              FUNC, SRC1, SRC2, RES, USR_RES)
484 
485 #define TEST_R_OP_RR(FUNC, SRC1, SRC2, RES, USR_RES) \
486 TEST_x_OP_xx(uint32_t, check32, uint32_t, uint32_t, \
487              FUNC, SRC1, SRC2, RES, USR_RES)
488 
489 #define TEST_R_OP_PR(FUNC, SRC1, SRC2, RES, USR_RES) \
490 TEST_x_OP_xx(uint32_t, check32, uint64_t, uint32_t, \
491              FUNC, SRC1, SRC2, RES, USR_RES)
492 
493 #define TEST_P_OP_PR(FUNC, SRC1, SRC2, RES, USR_RES) \
494 TEST_x_OP_xx(uint64_t, check64, uint64_t, uint32_t, \
495              FUNC, SRC1, SRC2, RES, USR_RES)
496 
497 #define TEST_xp_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, FUNC, SRC1, SRC2, \
498                       RES, PRED_RES, USR_RES) \
499     do { \
500         RESTYPE result; \
501         SRC1TYPE src1 = SRC1; \
502         SRC2TYPE src2 = SRC2; \
503         uint8_t pred_result; \
504         uint32_t usr_result; \
505         result = FUNC(src1, src2, &pred_result, &usr_result); \
506         CHECKFN(result, RES); \
507         check32(pred_result, PRED_RES); \
508         check32(usr_result, USR_RES); \
509     } while (0)
510 
511 #define TEST_Rp_OP_RR(FUNC, SRC1, SRC2, RES, PRED_RES, USR_RES) \
512 TEST_xp_OP_xx(uint32_t, check32, uint32_t, uint32_t, FUNC, SRC1, SRC2, \
513               RES, PRED_RES, USR_RES)
514 
515 #define TEST_x_OP_xI(RESTYPE, CHECKFN, SRC1TYPE, \
516                      FUNC, SRC1, SRC2, RES, USR_RES) \
517     do { \
518         RESTYPE result; \
519         SRC1TYPE src1 = SRC1; \
520         uint32_t src2 = SRC2; \
521         uint32_t usr_result; \
522         result = FUNC(src1, src2, &usr_result); \
523         CHECKFN(result, RES); \
524         check32(usr_result, USR_RES); \
525     } while (0)
526 
527 #define TEST_R_OP_RI(FUNC, SRC1, SRC2, RES, USR_RES) \
528 TEST_x_OP_xI(uint32_t, check32, uint32_t, \
529              FUNC, SRC1, SRC2, RES, USR_RES)
530 
531 #define TEST_R_OP_PI(FUNC, SRC1, SRC2, RES, USR_RES) \
532 TEST_x_OP_xI(uint32_t, check64, uint64_t, \
533              FUNC, SRC1, SRC2, RES, USR_RES)
534 
535 #define TEST_Xx_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \
536                       FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \
537     do { \
538         RESTYPE result = RESIN; \
539         SRC1TYPE src1 = SRC1; \
540         SRC2TYPE src2 = SRC2; \
541         uint32_t usr_result; \
542         result = FUNC(result, src1, src2, &usr_result); \
543         CHECKFN(result, RES); \
544         check32(usr_result, USR_RES); \
545     } while (0)
546 
547 #define TEST_XR_OP_RR(FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \
548 TEST_Xx_OP_xx(uint32_t, check32, uint32_t, uint32_t, \
549               FUNC, RESIN, SRC1, SRC2, RES, USR_RES)
550 
551 #define TEST_XP_OP_PP(FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \
552 TEST_Xx_OP_xx(uint64_t, check64, uint64_t, uint64_t, \
553               FUNC, RESIN, SRC1, SRC2, RES, USR_RES)
554 
555 #define TEST_XP_OP_RR(FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \
556 TEST_Xx_OP_xx(uint64_t, check64, uint32_t, uint32_t, \
557               FUNC, RESIN, SRC1, SRC2, RES, USR_RES)
558 
559 #define TEST_Xxp_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \
560                        FUNC, RESIN, SRC1, SRC2, RES, PRED_RES, USR_RES) \
561     do { \
562         RESTYPE result = RESIN; \
563         SRC1TYPE src1 = SRC1; \
564         SRC2TYPE src2 = SRC2; \
565         uint8_t pred_res; \
566         uint32_t usr_result; \
567         result = FUNC(result, src1, src2, &pred_res, &usr_result); \
568         CHECKFN(result, RES); \
569         check32(usr_result, USR_RES); \
570     } while (0)
571 
572 #define TEST_XPp_OP_PP(FUNC, RESIN, SRC1, SRC2, RES, PRED_RES, USR_RES) \
573 TEST_Xxp_OP_xx(uint64_t, check64, uint64_t, uint64_t, FUNC, RESIN, SRC1, SRC2, \
574                RES, PRED_RES, USR_RES)
575 
576 #define TEST_Xx_OP_xxp(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \
577                       FUNC, RESIN, SRC1, SRC2, PRED, RES, USR_RES) \
578     do { \
579         RESTYPE result = RESIN; \
580         SRC1TYPE src1 = SRC1; \
581         SRC2TYPE src2 = SRC2; \
582         uint8_t pred = PRED; \
583         uint32_t usr_result; \
584         result = FUNC(result, src1, src2, pred, &usr_result); \
585         CHECKFN(result, RES); \
586         check32(usr_result, USR_RES); \
587     } while (0)
588 
589 #define TEST_XR_OP_RRp(FUNC, RESIN, SRC1, SRC2, PRED, RES, USR_RES) \
590 TEST_Xx_OP_xxp(uint32_t, check32, uint32_t, uint32_t, \
591               FUNC, RESIN, SRC1, SRC2, PRED, RES, USR_RES)
592 
593 #define TEST_CMP_xx(SRC1TYPE, SRC2TYPE, \
594                     FUNC, SRC1, SRC2, RES, USR_RES) \
595     do { \
596         uint32_t result; \
597         SRC1TYPE src1 = SRC1; \
598         SRC2TYPE src2 = SRC2; \
599         uint32_t usr_result; \
600         result = FUNC(src1, src2, &usr_result); \
601         check32(result, RES); \
602         check32(usr_result, USR_RES); \
603     } while (0)
604 
605 #define TEST_CMP_RR(FUNC, SRC1, SRC2, RES, USR_RES) \
606 TEST_CMP_xx(uint32_t, uint32_t, FUNC, SRC1, SRC2, RES, USR_RES)
607 
608 #define TEST_CMP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \
609 TEST_CMP_xx(uint64_t, uint64_t, FUNC, SRC1, SRC2, RES, USR_RES)
610 
611 int main()
612 {
613     TEST_R_OP_R(satub,       0,         0,         USR_CLEAR);
614     TEST_R_OP_R(satub,       0xff,      0xff,      USR_CLEAR);
615     TEST_R_OP_R(satub,       0xfff,     0xff,      USR_OVF);
616     TEST_R_OP_R(satub,       -1,        0,         USR_OVF);
617 
618     TEST_P_OP_PP(vaddubs,    0xfeLL,    0x01LL,    0xffLL,    USR_CLEAR);
619     TEST_P_OP_PP(vaddubs,    0xffLL,    0xffLL,    0xffLL,    USR_OVF);
620 
621     TEST_P_OP_PP(vadduhs,    0xfffeLL,  0x1LL,     0xffffLL,  USR_CLEAR);
622     TEST_P_OP_PP(vadduhs,    0xffffLL,  0x1LL,     0xffffLL,  USR_OVF);
623 
624     TEST_P_OP_PP(vsububs, 0x0807060504030201LL, 0x0101010101010101LL,
625                  0x0706050403020100LL, USR_CLEAR);
626     TEST_P_OP_PP(vsububs, 0x0807060504030201LL, 0x0202020202020202LL,
627                  0x0605040302010000LL, USR_OVF);
628 
629     TEST_P_OP_PP(vsubuhs, 0x0004000300020001LL, 0x0001000100010001LL,
630                  0x0003000200010000LL, USR_CLEAR);
631     TEST_P_OP_PP(vsubuhs, 0x0004000300020001LL, 0x0002000200020002LL,
632                  0x0002000100000000LL, USR_OVF);
633 
634     TEST_R_OP_PP(vaddhubs, 0x0004000300020001LL, 0x0001000100010001LL,
635                  0x05040302, USR_CLEAR);
636     TEST_R_OP_PP(vaddhubs, 0x7fff000300020001LL, 0x0002000200020002LL,
637                  0xff050403, USR_OVF);
638 
639     TEST_R_OP_P(vsathub,         0x0001000300020001LL, 0x01030201, USR_CLEAR);
640     TEST_R_OP_P(vsathub,         0x010000700080ffffLL, 0xff708000, USR_OVF);
641 
642     TEST_R_OP_P(vsatwuh,         0x0000ffff00000001LL, 0xffff0001, USR_CLEAR);
643     TEST_R_OP_P(vsatwuh,         0x800000000000ffffLL, 0x0000ffff, USR_OVF);
644 
645     TEST_P_OP_P(vsatwuh_nopack,  0x0000ffff00000001LL, 0x0000ffff00000001LL,
646                 USR_CLEAR);
647     TEST_P_OP_P(vsatwuh_nopack,  0x800000000000ffffLL, 0x000000000000ffffLL,
648                 USR_OVF);
649 
650     TEST_R_OP_R(svsathub,        0x00020001,           0x0201,     USR_CLEAR);
651     TEST_R_OP_R(svsathub,        0x0080ffff,           0x8000,     USR_OVF);
652 
653     TEST_R_OP_PI(asrhub_sat,     0x004f003f002f001fLL, 3,    0x09070503,
654                  USR_CLEAR);
655     TEST_R_OP_PI(asrhub_sat,     0x004fffff8fff001fLL, 3,    0x09000003,
656                  USR_OVF);
657 
658     TEST_R_OP_PI(asrhub_rnd_sat, 0x004f003f002f001fLL, 2,    0x0a080604,
659                  USR_CLEAR);
660     TEST_R_OP_PI(asrhub_rnd_sat, 0x004fffff8fff001fLL, 2,    0x0a000004,
661                  USR_OVF);
662 
663     TEST_R_OP_RR(addsat,        1,              2,              3,
664                  USR_CLEAR);
665     TEST_R_OP_RR(addsat,        0x7fffffff,     0x00000010,     0x7fffffff,
666                  USR_OVF);
667     TEST_R_OP_RR(addsat,        0x80000000,     0x80000006,     0x80000000,
668                  USR_OVF);
669 
670     TEST_P_OP_PP(addpsat, 1LL, 2LL, 3LL, USR_CLEAR);
671     /* overflow to max positive */
672     TEST_P_OP_PP(addpsat, 0x7ffffffffffffff0LL, 0x0000000000000010LL,
673                  0x7fffffffffffffffLL, USR_OVF);
674     /* overflow to min negative */
675     TEST_P_OP_PP(addpsat, 0x8000000000000003LL, 0x8000000000000006LL,
676                  0x8000000000000000LL, USR_OVF);
677 
678     TEST_XR_OP_RR(mpy_acc_sat_hh_s0, 0x7fffffff, 0xffff0000, 0x11110000,
679                   0x7fffeeee, USR_CLEAR);
680     TEST_XR_OP_RR(mpy_acc_sat_hh_s0, 0x7fffffff, 0x7fff0000, 0x7fff0000,
681                   0x7fffffff, USR_OVF);
682 
683     TEST_R_OP_RR(mpy_sat_hh_s1,        0xffff0000, 0x11110000, 0xffffddde,
684                  USR_CLEAR);
685     TEST_R_OP_RR(mpy_sat_hh_s1,        0x7fff0000, 0x7fff0000, 0x7ffe0002,
686                  USR_CLEAR);
687     TEST_R_OP_RR(mpy_sat_hh_s1,        0x80000000, 0x80000000, 0x7fffffff,
688                  USR_OVF);
689 
690     TEST_R_OP_RR(mpy_sat_rnd_hh_s1,    0xffff0000, 0x11110000, 0x00005dde,
691                  USR_CLEAR);
692     TEST_R_OP_RR(mpy_sat_rnd_hh_s1,    0x7fff0000, 0x7fff0000, 0x7ffe8002,
693                  USR_CLEAR);
694     TEST_R_OP_RR(mpy_sat_rnd_hh_s1,    0x80000000, 0x80000000, 0x7fffffff,
695                  USR_OVF);
696 
697     TEST_R_OP_RR(mpy_up_s1_sat,        0xffff0000, 0x11110000, 0xffffddde,
698                  USR_CLEAR);
699     TEST_R_OP_RR(mpy_up_s1_sat,        0x7fff0000, 0x7fff0000, 0x7ffe0002,
700                  USR_CLEAR);
701     TEST_R_OP_RR(mpy_up_s1_sat,        0x80000000, 0x80000000, 0x7fffffff,
702                  USR_OVF);
703 
704     TEST_P_OP_RR(vmpy2s_s1,  0x7fff0000, 0x7fff0000, 0x7ffe000200000000LL,
705                  USR_CLEAR);
706     TEST_P_OP_RR(vmpy2s_s1,  0x80000000, 0x80000000, 0x7fffffff00000000LL,
707                  USR_OVF);
708 
709     TEST_P_OP_RR(vmpy2su_s1, 0x7fff0000, 0x7fff0000, 0x7ffe000200000000LL,
710                  USR_CLEAR);
711     TEST_P_OP_RR(vmpy2su_s1, 0xffffbd97, 0xffffffff, 0xfffe000280000000LL,
712                  USR_OVF);
713 
714     TEST_R_OP_RR(vmpy2s_s1pack,        0x7fff0000, 0x7fff0000, 0x7ffe0000,
715                  USR_CLEAR);
716     TEST_R_OP_RR(vmpy2s_s1pack,        0x80008000, 0x80008000, 0x7fff7fff,
717                  USR_OVF);
718 
719     TEST_P_OP_PP(vmpy2es_s1, 0x7fff7fff7fff7fffLL, 0x1fff1fff1fff1fffLL,
720                  0x1ffec0021ffec002LL, USR_CLEAR);
721     TEST_P_OP_PP(vmpy2es_s1, 0x8000800080008000LL, 0x8000800080008000LL,
722                  0x7fffffff7fffffffLL, USR_OVF);
723 
724     TEST_R_OP_PP(vdmpyrs_s1, 0x7fff7fff7fff7fffLL, 0x1fff1fff1fff1fffLL,
725                  0x3ffe3ffe, USR_CLEAR);
726     TEST_R_OP_PP(vdmpyrs_s1, 0x8000800080008000LL, 0x8000800080008000LL,
727                  0x7fff7fffLL, USR_OVF);
728 
729     TEST_XP_OP_PP(vdmacs_s0, 0x0fffffffULL, 0x00ff00ff00ff00ffLL,
730                   0x00ff00ff00ff00ffLL, 0x0001fc021001fc01LL, USR_CLEAR);
731     TEST_XP_OP_PP(vdmacs_s0, 0x01111111ULL, 0x8000800080001000LL,
732                   0x8000800080008000LL, 0x7fffffff39111111LL, USR_OVF);
733 
734     TEST_R_OP_RR(cmpyrs_s0,            0x7fff0000, 0x7fff0000, 0x0000c001,
735                  USR_CLEAR);
736     TEST_R_OP_RR(cmpyrs_s0,            0x80008000, 0x80008000, 0x7fff0000,
737                  USR_OVF);
738 
739     TEST_XP_OP_RR(cmacs_s0, 0x0fffffff, 0x7fff0000, 0x7fff0000,
740                   0x00000000d000fffeLL, USR_CLEAR);
741     TEST_XP_OP_RR(cmacs_s0, 0x0fff1111, 0x80008000, 0x80008000,
742                   0x7fffffff0fff1111LL, USR_OVF);
743 
744     TEST_XP_OP_RR(cnacs_s0, 0x000000108fffffffULL, 0x7fff0000, 0x7fff0000,
745                   0x00000010cfff0000ULL, USR_CLEAR);
746     TEST_XP_OP_RR(cnacs_s0, 0x000000108ff1111fULL, 0x00002001, 0x00007ffd,
747                   0x0000001080000000ULL, USR_OVF);
748 
749     TEST_P_OP_PP(vrcmpys_s1_h, 0x00ff00ff00ff00ffLL, 0x00ff00ff00ff00ffLL,
750                  0x0003f8040003f804LL, USR_CLEAR);
751     TEST_P_OP_PP(vrcmpys_s1_h, 0x8000800080008000LL, 0x8000800080008000LL,
752                  0x7fffffff7fffffffLL, USR_OVF);
753 
754     TEST_XP_OP_PP(mmacls_s0, 0x6fffffff, 0x00ff00ff00ff00ffLL,
755                   0x00ff00ff00ff00ffLL, 0x0000fe017000fe00LL, USR_CLEAR);
756     TEST_XP_OP_PP(mmacls_s0, 0x6f1111ff, 0x8000800080008000LL,
757                   0x1000100080008000LL, 0xf80008007fffffffLL, USR_OVF);
758 
759     TEST_R_OP_RR(hmmpyl_rs1,           0x7fff0000, 0x7fff0001, 0x0000fffe,
760                  USR_CLEAR);
761     TEST_R_OP_RR(hmmpyl_rs1,           0x80000000, 0x80008000, 0x7fffffff,
762                  USR_OVF);
763 
764     TEST_XP_OP_PP(mmaculs_s0, 0x000000007fffffffULL, 0xffff800080008000LL,
765                   0xffff800080008000LL, 0xffffc00040003fffLL, USR_CLEAR);
766     TEST_XP_OP_PP(mmaculs_s0, 0x000011107fffffffULL, 0x00ff00ff00ff00ffLL,
767                   0x00ff00ff001100ffLL, 0x00010f117fffffffLL, USR_OVF);
768 
769     TEST_R_OP_PR(cmpyi_wh, 0x7fff000000000000LL, 0x7fff0001, 0x0000fffe,
770                  USR_CLEAR);
771     TEST_R_OP_PR(cmpyi_wh, 0x8000000000000000LL, 0x80008000, 0x7fffffff,
772                  USR_OVF);
773 
774     TEST_P_OP_PP(vcmpy_s0_sat_i, 0x00ff00ff00ff00ffLL, 0x00ff00ff00ff00ffLL,
775                  0x0001fc020001fc02LL, USR_CLEAR);
776     TEST_P_OP_PP(vcmpy_s0_sat_i, 0x8000800080008000LL, 0x8000800080008000LL,
777                  0x7fffffff7fffffffLL, USR_OVF);
778 
779     TEST_P_OP_PR(vcrotate, 0x8000000000000000LL, 0x00000002,
780                  0x8000000000000000LL, USR_CLEAR);
781     TEST_P_OP_PR(vcrotate, 0x7fff80007fff8000LL, 0x00000001,
782                  0x7fff80007fff7fffLL, USR_OVF);
783 
784     TEST_P_OP_PR(vcnegh, 0x8000000000000000LL, 0x00000002,
785                  0x8000000000000000LL, USR_CLEAR);
786     TEST_P_OP_PR(vcnegh, 0x7fff80007fff8000LL, 0x00000001,
787                  0x7fff80007fff7fffLL, USR_OVF);
788 
789 #if CORE_HAS_AUDIO
790     TEST_R_OP_PP(wcmpyrw, 0x8765432101234567LL, 0x00000002ffffffffLL,
791                  0x00000001, USR_CLEAR);
792     TEST_R_OP_PP(wcmpyrw, 0x800000007fffffffLL, 0x000000ff7fffffffLL,
793                  0x7fffffff, USR_OVF);
794     TEST_R_OP_PP(wcmpyrw, 0x7fffffff80000000LL, 0x7fffffff000000ffLL,
795                  0x80000000, USR_OVF);
796 #else
797     printf("Audio instructions skipped\n");
798 #endif
799 
800     TEST_R_OP_RR(addh_l16_sat_ll,      0x0000ffff, 0x00000002, 0x00000001,
801                  USR_CLEAR);
802     TEST_R_OP_RR(addh_l16_sat_ll,      0x00007fff, 0x00000005, 0x00007fff,
803                  USR_OVF);
804     TEST_R_OP_RR(addh_l16_sat_ll,      0x00008000, 0x00008000, 0xffff8000,
805                  USR_OVF);
806 
807     TEST_P_OP_P(vconj, 0x0000ffff00000001LL, 0x0000ffff00000001LL, USR_CLEAR);
808     TEST_P_OP_P(vconj, 0x800000000000ffffLL, 0x7fff00000000ffffLL, USR_OVF);
809 
810     TEST_P_OP_PP(vxaddsubw, 0x8765432101234567LL, 0x00000002ffffffffLL,
811                  0x8765432201234569LL, USR_CLEAR);
812     TEST_P_OP_PP(vxaddsubw, 0x7fffffff7fffffffLL, 0xffffffffffffffffLL,
813                  0x7fffffff7ffffffeLL, USR_OVF);
814     TEST_P_OP_PP(vxaddsubw, 0x800000000fffffffLL, 0x0000000a00000008LL,
815                  0x8000000010000009LL, USR_OVF);
816 
817     TEST_P_OP_P(vabshsat, 0x0001000afffff800LL, 0x0001000a00010800LL,
818                 USR_CLEAR);
819     TEST_P_OP_P(vabshsat, 0x8000000b000c000aLL, 0x7fff000b000c000aLL,
820              USR_OVF);
821 
822     TEST_P_OP_PP(vnavgwr, 0x8765432101234567LL, 0x00000002ffffffffLL,
823                  0xc3b2a1900091a2b4LL, USR_CLEAR);
824     TEST_P_OP_PP(vnavgwr, 0x7fffffff8000000aLL, 0x80000000ffffffffLL,
825                  0x7fffffffc0000006LL, USR_OVF);
826 
827     TEST_R_OP_RI(round_ri_sat,         0x0000ffff, 2, 0x00004000, USR_CLEAR);
828     TEST_R_OP_RI(round_ri_sat,         0x7fffffff, 2, 0x1fffffff, USR_OVF);
829 
830     TEST_R_OP_RR(asr_r_r_sat,  0x0000ffff, 0x02, 0x00003fff, USR_CLEAR);
831     TEST_R_OP_RR(asr_r_r_sat,  0x80000000, 0x01, 0xc0000000, USR_CLEAR);
832     TEST_R_OP_RR(asr_r_r_sat,  0xffffffff, 0x01, 0xffffffff, USR_CLEAR);
833     TEST_R_OP_RR(asr_r_r_sat,  0x00ffffff, 0xf5, 0x7fffffff, USR_OVF);
834     TEST_R_OP_RR(asr_r_r_sat,  0x80000000, 0xf5, 0x80000000, USR_OVF);
835     TEST_R_OP_RR(asr_r_r_sat,  0x7fff0000, 0x42, 0x7fffffff, USR_OVF);
836     TEST_R_OP_RR(asr_r_r_sat,  0xff000000, 0x42, 0x80000000, USR_OVF);
837     TEST_R_OP_RR(asr_r_r_sat,        4096,   32, 0x00000000, USR_CLEAR);
838     TEST_R_OP_RR(asr_r_r_sat,        4096,  -32, 0x7fffffff, USR_OVF);
839     TEST_R_OP_RR(asr_r_r_sat,       -4096,   32, 0xffffffff, USR_CLEAR);
840     TEST_R_OP_RR(asr_r_r_sat,       -4096,  -32, 0x80000000, USR_OVF);
841     TEST_R_OP_RR(asr_r_r_sat,           0,  -32, 0x00000000, USR_CLEAR);
842     TEST_R_OP_RR(asr_r_r_sat,           1,  -32, 0x7fffffff, USR_OVF);
843 
844     TEST_R_OP_RR(asl_r_r_sat,  0x00000000, 0x40, 0x00000000, USR_CLEAR);
845     TEST_R_OP_RR(asl_r_r_sat,  0x80000000, 0xff, 0xc0000000, USR_CLEAR);
846     TEST_R_OP_RR(asl_r_r_sat,  0xffffffff, 0xff, 0xffffffff, USR_CLEAR);
847     TEST_R_OP_RR(asl_r_r_sat,  0x00ffffff, 0x0b, 0x7fffffff, USR_OVF);
848     TEST_R_OP_RR(asl_r_r_sat,  0x80000000, 0x0b, 0x80000000, USR_OVF);
849     TEST_R_OP_RR(asl_r_r_sat,  0x7fff0000, 0xbe, 0x7fffffff, USR_OVF);
850     TEST_R_OP_RR(asl_r_r_sat,  0xff000000, 0xbe, 0x80000000, USR_OVF);
851     TEST_R_OP_RR(asl_r_r_sat,        4096,   32, 0x7fffffff, USR_OVF);
852     TEST_R_OP_RR(asl_r_r_sat,        4096,  -32, 0x00000000, USR_CLEAR);
853     TEST_R_OP_RR(asl_r_r_sat,       -4096,   32, 0x80000000, USR_OVF);
854     TEST_R_OP_RR(asl_r_r_sat,       -4096,  -32, 0xffffffff, USR_CLEAR);
855     TEST_R_OP_RR(asl_r_r_sat,           0,   32, 0x00000000, USR_CLEAR);
856     TEST_R_OP_RR(asl_r_r_sat,           1,   32, 0x7fffffff, USR_OVF);
857 
858     TEST_XPp_OP_PP(ACS, 0x0004000300020001ULL, 0x0001000200030004ULL,
859                    0x0000000000000000ULL, 0x0004000300030004ULL, 0xf0,
860                    USR_CLEAR);
861     TEST_XPp_OP_PP(ACS, 0x0004000300020001ULL, 0x0001000200030004ULL,
862                    0x000affff000d0000ULL, 0x000e0003000f0004ULL, 0xcc,
863                    USR_CLEAR);
864     TEST_XPp_OP_PP(ACS, 0x00047fff00020001ULL, 0x00017fff00030004ULL,
865                   0x000a0fff000d0000ULL, 0x000e7fff000f0004ULL, 0xfc,
866                   USR_OVF);
867     TEST_XPp_OP_PP(ACS, 0x00047fff00020001ULL, 0x00017fff00030004ULL,
868                    0x000a0fff000d0000ULL, 0x000e7fff000f0004ULL, 0xf0,
869                    USR_OVF);
870 
871     /* Floating point */
872     TEST_R_OP_RR(sfmin,  SF_one,      SF_small_neg,   SF_small_neg, USR_CLEAR);
873     TEST_R_OP_RR(sfmin,  SF_one,      SF_SNaN,        SF_one,       USR_FPINVF);
874     TEST_R_OP_RR(sfmin,  SF_SNaN,     SF_one,         SF_one,       USR_FPINVF);
875     TEST_R_OP_RR(sfmin,  SF_one,      SF_QNaN,        SF_one,       USR_CLEAR);
876     TEST_R_OP_RR(sfmin,  SF_QNaN,     SF_one,         SF_one,       USR_CLEAR);
877     TEST_R_OP_RR(sfmin,  SF_SNaN,     SF_QNaN,        SF_HEX_NaN,   USR_FPINVF);
878     TEST_R_OP_RR(sfmin,  SF_QNaN,     SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
879     TEST_R_OP_RR(sfmin,  SF_zero,     SF_zero_neg,    SF_zero_neg,  USR_CLEAR);
880     TEST_R_OP_RR(sfmin,  SF_zero_neg, SF_zero,        SF_zero_neg,  USR_CLEAR);
881 
882     TEST_R_OP_RR(sfmax,  SF_one,      SF_small_neg,   SF_one,       USR_CLEAR);
883     TEST_R_OP_RR(sfmax,  SF_one,      SF_SNaN,        SF_one,       USR_FPINVF);
884     TEST_R_OP_RR(sfmax,  SF_SNaN,     SF_one,         SF_one,       USR_FPINVF);
885     TEST_R_OP_RR(sfmax,  SF_one,      SF_QNaN,        SF_one,       USR_CLEAR);
886     TEST_R_OP_RR(sfmax,  SF_QNaN,     SF_one,         SF_one,       USR_CLEAR);
887     TEST_R_OP_RR(sfmax,  SF_SNaN,     SF_QNaN,        SF_HEX_NaN,   USR_FPINVF);
888     TEST_R_OP_RR(sfmax,  SF_QNaN,     SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
889     TEST_R_OP_RR(sfmax,  SF_zero,     SF_zero_neg,    SF_zero,      USR_CLEAR);
890     TEST_R_OP_RR(sfmax,  SF_zero_neg, SF_zero,        SF_zero,      USR_CLEAR);
891 
892     TEST_R_OP_RR(sfadd,  SF_one,      SF_QNaN,        SF_HEX_NaN,   USR_CLEAR);
893     TEST_R_OP_RR(sfadd,  SF_one,      SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
894     TEST_R_OP_RR(sfadd,  SF_QNaN,     SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
895     TEST_R_OP_RR(sfadd,  SF_SNaN,     SF_QNaN,        SF_HEX_NaN,   USR_FPINVF);
896 
897     TEST_R_OP_RR(sfsub,  SF_one,      SF_QNaN,        SF_HEX_NaN,   USR_CLEAR);
898     TEST_R_OP_RR(sfsub,  SF_one,      SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
899     TEST_R_OP_RR(sfsub,  SF_QNaN,     SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
900     TEST_R_OP_RR(sfsub,  SF_SNaN,     SF_QNaN,        SF_HEX_NaN,   USR_FPINVF);
901 
902     TEST_R_OP_RR(sfmpy,  SF_one,      SF_QNaN,        SF_HEX_NaN,   USR_CLEAR);
903     TEST_R_OP_RR(sfmpy,  SF_one,      SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
904     TEST_R_OP_RR(sfmpy,  SF_QNaN,     SF_SNaN,        SF_HEX_NaN,   USR_FPINVF);
905     TEST_R_OP_RR(sfmpy,  SF_SNaN,     SF_QNaN,        SF_HEX_NaN,   USR_FPINVF);
906 
907     TEST_XR_OP_RR(sffma, SF_one,   SF_one,    SF_one,   SF_two,     USR_CLEAR);
908     TEST_XR_OP_RR(sffma, SF_zero,  SF_one,    SF_QNaN,  SF_HEX_NaN, USR_CLEAR);
909     TEST_XR_OP_RR(sffma, SF_zero,  SF_one,    SF_SNaN,  SF_HEX_NaN, USR_FPINVF);
910     TEST_XR_OP_RR(sffma, SF_zero,  SF_QNaN,   SF_SNaN,  SF_HEX_NaN, USR_FPINVF);
911     TEST_XR_OP_RR(sffma, SF_zero,  SF_SNaN,   SF_QNaN,  SF_HEX_NaN, USR_FPINVF);
912 
913     TEST_XR_OP_RR(sffms, SF_one,   SF_one,    SF_one,   SF_zero,    USR_CLEAR);
914     TEST_XR_OP_RR(sffms, SF_zero,  SF_one,    SF_QNaN,  SF_HEX_NaN, USR_CLEAR);
915     TEST_XR_OP_RR(sffms, SF_zero,  SF_one,    SF_SNaN,  SF_HEX_NaN, USR_FPINVF);
916     TEST_XR_OP_RR(sffms, SF_zero,  SF_QNaN,   SF_SNaN,  SF_HEX_NaN, USR_FPINVF);
917     TEST_XR_OP_RR(sffms, SF_zero,  SF_SNaN,   SF_QNaN,  SF_HEX_NaN, USR_FPINVF);
918 
919     TEST_CMP_RR(sfcmpuo, SF_one,      SF_large_pos,    0x00,    USR_CLEAR);
920     TEST_CMP_RR(sfcmpuo, SF_INF,      SF_large_pos,    0x00,    USR_CLEAR);
921     TEST_CMP_RR(sfcmpuo, SF_QNaN,     SF_large_pos,    0xff,    USR_CLEAR);
922     TEST_CMP_RR(sfcmpuo, SF_QNaN_neg, SF_large_pos,    0xff,    USR_CLEAR);
923     TEST_CMP_RR(sfcmpuo, SF_SNaN,     SF_large_pos,    0xff,    USR_FPINVF);
924     TEST_CMP_RR(sfcmpuo, SF_SNaN_neg, SF_large_pos,    0xff,    USR_FPINVF);
925     TEST_CMP_RR(sfcmpuo, SF_QNaN,     SF_QNaN,         0xff,    USR_CLEAR);
926     TEST_CMP_RR(sfcmpuo, SF_QNaN,     SF_SNaN,         0xff,    USR_FPINVF);
927 
928     TEST_CMP_RR(sfcmpeq, SF_one,      SF_QNaN,         0x00,    USR_CLEAR);
929     TEST_CMP_RR(sfcmpeq, SF_one,      SF_SNaN,         0x00,    USR_FPINVF);
930     TEST_CMP_RR(sfcmpgt, SF_one,      SF_QNaN,         0x00,    USR_CLEAR);
931     TEST_CMP_RR(sfcmpgt, SF_one,      SF_SNaN,         0x00,    USR_FPINVF);
932     TEST_CMP_RR(sfcmpge, SF_one,      SF_QNaN,         0x00,    USR_CLEAR);
933     TEST_CMP_RR(sfcmpge, SF_one,      SF_SNaN,         0x00,    USR_FPINVF);
934 
935     TEST_P_OP_PP(dfadd,  DF_any,    DF_QNaN,         DF_HEX_NaN,    USR_CLEAR);
936     TEST_P_OP_PP(dfadd,  DF_any,    DF_SNaN,         DF_HEX_NaN,    USR_FPINVF);
937     TEST_P_OP_PP(dfadd,  DF_QNaN,   DF_SNaN,         DF_HEX_NaN,    USR_FPINVF);
938     TEST_P_OP_PP(dfadd,  DF_SNaN,   DF_QNaN,         DF_HEX_NaN,    USR_FPINVF);
939 
940     TEST_P_OP_PP(dfsub,  DF_any,    DF_QNaN,         DF_HEX_NaN,    USR_CLEAR);
941     TEST_P_OP_PP(dfsub,  DF_any,    DF_SNaN,         DF_HEX_NaN,    USR_FPINVF);
942     TEST_P_OP_PP(dfsub,  DF_QNaN,   DF_SNaN,         DF_HEX_NaN,    USR_FPINVF);
943     TEST_P_OP_PP(dfsub,  DF_SNaN,   DF_QNaN,         DF_HEX_NaN,    USR_FPINVF);
944 
945 #if CORE_IS_V67
946     TEST_P_OP_PP(dfmin,  DF_any,    DF_small_neg,    DF_small_neg,  USR_CLEAR);
947     TEST_P_OP_PP(dfmin,  DF_any,    DF_SNaN,         DF_any,        USR_FPINVF);
948     TEST_P_OP_PP(dfmin,  DF_SNaN,   DF_any,          DF_any,        USR_FPINVF);
949     TEST_P_OP_PP(dfmin,  DF_any,    DF_QNaN,         DF_any,        USR_CLEAR);
950     TEST_P_OP_PP(dfmin,  DF_QNaN,   DF_any,          DF_any,        USR_CLEAR);
951     TEST_P_OP_PP(dfmin,  DF_SNaN,   DF_QNaN,         DF_HEX_NaN,    USR_FPINVF);
952     TEST_P_OP_PP(dfmin,  DF_QNaN,   DF_SNaN,         DF_HEX_NaN,    USR_FPINVF);
953     TEST_P_OP_PP(dfmin,  DF_zero,   DF_zero_neg,     DF_zero_neg,   USR_CLEAR);
954     TEST_P_OP_PP(dfmin,  DF_zero_neg, DF_zero,       DF_zero_neg,   USR_CLEAR);
955 
956     TEST_P_OP_PP(dfmax,  DF_any,    DF_small_neg,    DF_any,        USR_CLEAR);
957     TEST_P_OP_PP(dfmax,  DF_any,    DF_SNaN,         DF_any,        USR_FPINVF);
958     TEST_P_OP_PP(dfmax,  DF_SNaN,   DF_any,          DF_any,        USR_FPINVF);
959     TEST_P_OP_PP(dfmax,  DF_any,    DF_QNaN,         DF_any,        USR_CLEAR);
960     TEST_P_OP_PP(dfmax,  DF_QNaN,   DF_any,          DF_any,        USR_CLEAR);
961     TEST_P_OP_PP(dfmax,  DF_SNaN,   DF_QNaN,         DF_HEX_NaN,    USR_FPINVF);
962     TEST_P_OP_PP(dfmax,  DF_QNaN,   DF_SNaN,         DF_HEX_NaN,    USR_FPINVF);
963     TEST_P_OP_PP(dfmax,  DF_zero,   DF_zero_neg,     DF_zero,       USR_CLEAR);
964     TEST_P_OP_PP(dfmax,  DF_zero_neg, DF_zero,       DF_zero,       USR_CLEAR);
965 
966     TEST_XP_OP_PP(dfmpyhh, DF_one,   DF_one,  DF_one,   DF_one_hh,  USR_CLEAR);
967     TEST_XP_OP_PP(dfmpyhh, DF_zero,  DF_any,  DF_QNaN,  DF_HEX_NaN, USR_CLEAR);
968     TEST_XP_OP_PP(dfmpyhh, DF_zero,  DF_any,  DF_SNaN,  DF_HEX_NaN, USR_FPINVF);
969     TEST_XP_OP_PP(dfmpyhh, DF_zero,  DF_QNaN, DF_SNaN,  DF_HEX_NaN, USR_FPINVF);
970     TEST_XP_OP_PP(dfmpyhh, DF_zero,  DF_SNaN, DF_QNaN,  DF_HEX_NaN, USR_FPINVF);
971 #else
972     printf("v67 instructions skipped\n");
973 #endif
974 
975     TEST_CMP_PP(dfcmpuo, DF_small_neg, DF_any,          0x00,    USR_CLEAR);
976     TEST_CMP_PP(dfcmpuo, DF_large_pos, DF_any,          0x00,    USR_CLEAR);
977     TEST_CMP_PP(dfcmpuo, DF_QNaN,      DF_any,          0xff,    USR_CLEAR);
978     TEST_CMP_PP(dfcmpuo, DF_QNaN_neg,  DF_any,          0xff,    USR_CLEAR);
979     TEST_CMP_PP(dfcmpuo, DF_SNaN,      DF_any,          0xff,    USR_FPINVF);
980     TEST_CMP_PP(dfcmpuo, DF_SNaN_neg,  DF_any,          0xff,    USR_FPINVF);
981     TEST_CMP_PP(dfcmpuo, DF_QNaN,      DF_QNaN,         0xff,    USR_CLEAR);
982     TEST_CMP_PP(dfcmpuo, DF_QNaN,      DF_SNaN,         0xff,    USR_FPINVF);
983 
984     TEST_CMP_PP(dfcmpeq, DF_any,       DF_QNaN,         0x00,    USR_CLEAR);
985     TEST_CMP_PP(dfcmpeq, DF_any,       DF_SNaN,         0x00,    USR_FPINVF);
986     TEST_CMP_PP(dfcmpgt, DF_any,       DF_QNaN,         0x00,    USR_CLEAR);
987     TEST_CMP_PP(dfcmpgt, DF_any,       DF_SNaN,         0x00,    USR_FPINVF);
988     TEST_CMP_PP(dfcmpge, DF_any,       DF_QNaN,         0x00,    USR_CLEAR);
989     TEST_CMP_PP(dfcmpge, DF_any,       DF_SNaN,         0x00,    USR_FPINVF);
990 
991     TEST_P_OP_R(conv_sf2df,       SF_QNaN,  DF_HEX_NaN,             USR_CLEAR);
992     TEST_P_OP_R(conv_sf2df,       SF_SNaN,  DF_HEX_NaN,             USR_FPINVF);
993     TEST_R_OP_R(conv_sf2uw,       SF_QNaN,  0xffffffff,             USR_FPINVF);
994     TEST_R_OP_R(conv_sf2uw,       SF_SNaN,  0xffffffff,             USR_FPINVF);
995     TEST_R_OP_R(conv_sf2w,        SF_QNaN,  0xffffffff,             USR_FPINVF);
996     TEST_R_OP_R(conv_sf2w,        SF_SNaN,  0xffffffff,             USR_FPINVF);
997     TEST_P_OP_R(conv_sf2ud,       SF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
998     TEST_P_OP_R(conv_sf2ud,       SF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
999     TEST_P_OP_R(conv_sf2d,        SF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1000     TEST_P_OP_R(conv_sf2d,        SF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1001     TEST_R_OP_R(conv_sf2uw_chop,  SF_QNaN,  0xffffffff,             USR_FPINVF);
1002     TEST_R_OP_R(conv_sf2uw_chop,  SF_SNaN,  0xffffffff,             USR_FPINVF);
1003     TEST_R_OP_R(conv_sf2w_chop,   SF_QNaN,  0xffffffff,             USR_FPINVF);
1004     TEST_R_OP_R(conv_sf2w_chop,   SF_SNaN,  0xffffffff,             USR_FPINVF);
1005     TEST_P_OP_R(conv_sf2ud_chop,  SF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1006     TEST_P_OP_R(conv_sf2ud_chop,  SF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1007     TEST_P_OP_R(conv_sf2d_chop,   SF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1008     TEST_P_OP_R(conv_sf2d_chop,   SF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1009 
1010     TEST_R_OP_P(conv_df2sf,       DF_QNaN,  SF_HEX_NaN,             USR_CLEAR);
1011     TEST_R_OP_P(conv_df2sf,       DF_SNaN,  SF_HEX_NaN,             USR_FPINVF);
1012     TEST_R_OP_P(conv_df2uw,       DF_QNaN,  0xffffffff,             USR_FPINVF);
1013     TEST_R_OP_P(conv_df2uw,       DF_SNaN,  0xffffffff,             USR_FPINVF);
1014     TEST_R_OP_P(conv_df2w,        DF_QNaN,  0xffffffff,             USR_FPINVF);
1015     TEST_R_OP_P(conv_df2w,        DF_SNaN,  0xffffffff,             USR_FPINVF);
1016     TEST_P_OP_P(conv_df2ud,       DF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1017     TEST_P_OP_P(conv_df2ud,       DF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1018     TEST_P_OP_P(conv_df2d,        DF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1019     TEST_P_OP_P(conv_df2d,        DF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1020     TEST_R_OP_P(conv_df2uw_chop,  DF_QNaN,  0xffffffff,             USR_FPINVF);
1021     TEST_R_OP_P(conv_df2uw_chop,  DF_SNaN,  0xffffffff,             USR_FPINVF);
1022 
1023     /* Test for typo in HELPER(conv_df2uw_chop) */
1024     TEST_R_OP_P(conv_df2uw_chop, 0xffffff7f00000001ULL, 0xffffffff, USR_FPINVF);
1025 
1026     TEST_R_OP_P(conv_df2w_chop,   DF_QNaN,  0xffffffff,             USR_FPINVF);
1027     TEST_R_OP_P(conv_df2w_chop,   DF_SNaN,  0xffffffff,             USR_FPINVF);
1028     TEST_P_OP_P(conv_df2ud_chop,  DF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1029     TEST_P_OP_P(conv_df2ud_chop,  DF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1030     TEST_P_OP_P(conv_df2d_chop,   DF_QNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1031     TEST_P_OP_P(conv_df2d_chop,   DF_SNaN,  0xffffffffffffffffULL,  USR_FPINVF);
1032 
1033     TEST_R_OP_R(conv_uw2sf,    0x00000001,             SF_one,      USR_CLEAR);
1034     TEST_R_OP_R(conv_uw2sf,    0x010020a5,             0x4b801052,  USR_FPINPF);
1035     TEST_R_OP_R(conv_w2sf,     0x00000001,             SF_one,      USR_CLEAR);
1036     TEST_R_OP_R(conv_w2sf,     0x010020a5,             0x4b801052,  USR_FPINPF);
1037     TEST_R_OP_P(conv_ud2sf,    0x0000000000000001ULL,  SF_one,      USR_CLEAR);
1038     TEST_R_OP_P(conv_ud2sf,    0x00000000010020a5ULL,  0x4b801052,  USR_FPINPF);
1039     TEST_R_OP_P(conv_d2sf,     0x0000000000000001ULL,  SF_one,      USR_CLEAR);
1040     TEST_R_OP_P(conv_d2sf,     0x00000000010020a5ULL,  0x4b801052,  USR_FPINPF);
1041 
1042     TEST_XR_OP_RRp(sffma_sc, SF_one,   SF_one,    SF_one,   1, SF_four,
1043                    USR_CLEAR);
1044     TEST_XR_OP_RRp(sffma_sc, SF_QNaN,  SF_one,    SF_one,   1, SF_HEX_NaN,
1045                    USR_CLEAR);
1046     TEST_XR_OP_RRp(sffma_sc, SF_one,   SF_QNaN,   SF_one,   1, SF_HEX_NaN,
1047                    USR_CLEAR);
1048     TEST_XR_OP_RRp(sffma_sc, SF_one,   SF_one,    SF_QNaN,  1, SF_HEX_NaN,
1049                    USR_CLEAR);
1050     TEST_XR_OP_RRp(sffma_sc, SF_SNaN,  SF_one,    SF_one,   1, SF_HEX_NaN,
1051                    USR_FPINVF);
1052     TEST_XR_OP_RRp(sffma_sc, SF_one,   SF_SNaN,   SF_one,   1, SF_HEX_NaN,
1053                    USR_FPINVF);
1054     TEST_XR_OP_RRp(sffma_sc, SF_one,   SF_one,    SF_SNaN,  1, SF_HEX_NaN,
1055                    USR_FPINVF);
1056 
1057     TEST_Rp_OP_RR(sfrecipa, SF_one,    SF_one,    SF_one_recip,   0x00,
1058                   USR_CLEAR);
1059     TEST_Rp_OP_RR(sfrecipa, SF_QNaN,   SF_one,    SF_HEX_NaN,     0x00,
1060                   USR_CLEAR);
1061     TEST_Rp_OP_RR(sfrecipa, SF_one,    SF_QNaN,   SF_HEX_NaN,     0x00,
1062                   USR_CLEAR);
1063     TEST_Rp_OP_RR(sfrecipa, SF_one,    SF_SNaN,   SF_HEX_NaN,     0x00,
1064                   USR_FPINVF);
1065     TEST_Rp_OP_RR(sfrecipa, SF_SNaN,   SF_one,    SF_HEX_NaN,     0x00,
1066                   USR_FPINVF);
1067 
1068     TEST_R_OP_RR(sffixupn, SF_one,     SF_one,    SF_one,       USR_CLEAR);
1069     TEST_R_OP_RR(sffixupn, SF_QNaN,    SF_one,    SF_HEX_NaN,   USR_CLEAR);
1070     TEST_R_OP_RR(sffixupn, SF_one,     SF_QNaN,   SF_HEX_NaN,   USR_CLEAR);
1071     TEST_R_OP_RR(sffixupn, SF_SNaN,    SF_one,    SF_HEX_NaN,   USR_FPINVF);
1072     TEST_R_OP_RR(sffixupn, SF_one,     SF_SNaN,   SF_HEX_NaN,   USR_FPINVF);
1073 
1074     TEST_R_OP_RR(sffixupd, SF_one,     SF_one,    SF_one,       USR_CLEAR);
1075     TEST_R_OP_RR(sffixupd, SF_QNaN,    SF_one,    SF_HEX_NaN,   USR_CLEAR);
1076     TEST_R_OP_RR(sffixupd, SF_one,     SF_QNaN,   SF_HEX_NaN,   USR_CLEAR);
1077     TEST_R_OP_RR(sffixupd, SF_SNaN,    SF_one,    SF_HEX_NaN,   USR_FPINVF);
1078     TEST_R_OP_RR(sffixupd, SF_one,     SF_SNaN,   SF_HEX_NaN,   USR_FPINVF);
1079 
1080     TEST_R_OP_R(sffixupr, SF_one,             SF_one,           USR_CLEAR);
1081     TEST_R_OP_R(sffixupr, SF_QNaN,            SF_HEX_NaN,       USR_CLEAR);
1082     TEST_R_OP_R(sffixupr, SF_SNaN,            SF_HEX_NaN,       USR_FPINVF);
1083 
1084     TEST_Rp_OP_R(sfinvsqrta, SF_one,        SF_one_invsqrta,  0x00, USR_CLEAR);
1085     TEST_Rp_OP_R(sfinvsqrta, SF_zero,       SF_one,           0x00, USR_CLEAR);
1086     TEST_Rp_OP_R(sfinvsqrta, SF_QNaN,       SF_HEX_NaN,       0x00, USR_CLEAR);
1087     TEST_Rp_OP_R(sfinvsqrta, SF_small_neg,  SF_HEX_NaN,       0x00, USR_FPINVF);
1088     TEST_Rp_OP_R(sfinvsqrta, SF_SNaN,       SF_HEX_NaN,       0x00, USR_FPINVF);
1089 
1090     puts(err ? "FAIL" : "PASS");
1091     return err;
1092 }
1093