tests/fpu: Add tests for ftdiv and ftsqrt

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
pull/427/head
Paul Mackerras 9 months ago
parent f4d28d1521
commit 7f781b835d

@ -1665,6 +1665,65 @@ int fpu_test_25(void)
return 0;
}

struct ftvals {
unsigned long val_a;
unsigned long val_b;
int cr_ftdiv;
int cr_ftsqrt;
} ftvals[] = {
{ 0x3ff0000000000000, 0x3ff0000000000000, 0, 0 },
{ 0x0000000000000000, 0x3ff0000000000000, 0, 6 },
{ 0xfff0000000000000, 0x3ff0000000000000, 6, 6 },
{ 0x7ff1234560000000, 0x3ff0000000000000, 2, 2 },
{ 0x3ff0000000000000, 0xfff0000000000000, 6, 0 },
{ 0x3ff0000000000000, 0x8000000000000000, 6, 0 },
{ 0x3ff0000000000000, 0x7ff9234560000000, 2, 0 },
{ 0x3ff0000000000000, 0x0020000000000000, 0, 0 },
{ 0x3ff0000000000000, 0x0010000000000000, 2, 0 },
{ 0x3ff0000000000000, 0x0001000000000000, 6, 0 },
{ 0x3ff0000000000000, 0x7fb1234500000000, 0, 0 },
{ 0x3ff0000000000000, 0x7fc1234500000000, 2, 0 },
{ 0x3ff0000000000000, 0x7fd1234500000000, 2, 0 },
{ 0x3ff0000000000000, 0x7fe1234500000000, 2, 0 },
{ 0x6000000000000000, 0x2000000000000000, 2, 0 },
{ 0x5ff0000000000000, 0x2000000000000000, 2, 0 },
{ 0x5fe0000000000000, 0x2000000000000000, 0, 0 },
{ 0x2000000000000000, 0x5fc0000000000000, 0, 0 },
{ 0x2000000000000000, 0x5fd0000000000000, 2, 0 },
{ 0x0360000000000000, 0x4320000000000000, 0, 0 },
{ 0x0350000000000000, 0x4310000000000000, 2, 2 },
{ 0x0010000000000000, 0x3fd0000000000000, 2, 2 },
{ 0x0001000000000000, 0x3fd0000000000000, 2, 6 },
{ 0xbff0000000000000, 0x3ff0000000000000, 0, 2 },
{ 0x3fd0000000000000, 0x0001000000000000, 6, 0 },
};

int test26(long arg)
{
long i;
int cr;
struct ftvals *vp = ftvals;

set_fpscr(FPS_RN_NEAR);
for (i = 0; i < sizeof(ftvals) / sizeof(ftvals[0]); ++i, ++vp) {
asm("lfd 5,0(%1); lfd 6,8(%1); ftdiv 5,5,6; ftsqrt 4,5; mfcr %0" :
"=r" (cr) : "b" (&vp->val_a) : "cr4", "cr5");
if (((cr >> 8) & 0xf) != vp->cr_ftdiv ||
((cr >> 12) & 0x1f) != vp->cr_ftsqrt) {
print_hex(i, 2, " ");
print_hex(cr, 8, " ");
return i + 1;
}
}
return 0;
}

int fpu_test_26(void)
{
enable_fp();
return trapit(0, test26);
}

int fail = 0;

void do_test(int num, int (*test)(void))
@ -1715,6 +1774,7 @@ int main(void)
do_test(23, fpu_test_23);
do_test(24, fpu_test_24);
do_test(25, fpu_test_25);
do_test(26, fpu_test_26);

return fail;
}

Binary file not shown.

@ -23,3 +23,4 @@ test 22:PASS
test 23:PASS
test 24:PASS
test 25:PASS
test 26:PASS

Loading…
Cancel
Save