From e1bbb786c078b7ecdae7d027860d44949eb87bb2 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 30 Jul 2020 13:38:09 +1000 Subject: [PATCH] tests/fpu: Add tests for fsel and fcmpu Signed-off-by: Paul Mackerras --- tests/fpu/fpu.c | 98 +++++++++++++++++++++++++++++++++++++ tests/test_fpu.bin | Bin 24512 -> 25024 bytes tests/test_fpu.console_out | 2 + 3 files changed, 100 insertions(+) diff --git a/tests/fpu/fpu.c b/tests/fpu/fpu.c index e62ce27..06da475 100644 --- a/tests/fpu/fpu.c +++ b/tests/fpu/fpu.c @@ -1148,6 +1148,102 @@ int fpu_test_18(void) return trapit(0, test18); } +#define RES_B 0x7ffaaaaaaaaaaaaa +#define RES_C 0x000bbbbbbbbbbbbb + +struct selvals { + unsigned long val; + unsigned long result; +} selvals[] = { + { 0x0000000000000000, RES_C }, + { 0x8000000000000000, RES_C }, + { 0x3ff0000000000000, RES_C }, + { 0xbff0000000000000, RES_B }, + { 0x7ff0000000000000, RES_C }, + { 0xfff0000000000000, RES_B }, + { 0x7ff8000000000000, RES_B }, + { 0xfff8000000000000, RES_B }, + { 0x0000000000000001, RES_C }, + { 0x8000000000000001, RES_B }, + { 0xffffffffffffffff, RES_B }, +}; + +int test19(long arg) +{ + long i; + unsigned long result; + unsigned long frb = RES_B; + unsigned long frc = RES_C; + struct selvals *vp = selvals; + + for (i = 0; i < sizeof(selvals) / sizeof(selvals[0]); ++i, ++vp) { + asm("lfd 6,0(%0); lfd 10,0(%1); lfd 22,0(%2); fsel 0,6,22,10; stfd 0,0(%3)" + : : "b" (&vp->val), "b" (&frb), "b" (&frc), "b" (&result) : "memory"); + if (result != vp->result) { + print_hex(i, 2, " "); + print_hex(result, 16, " "); + return i + 1; + } + } + return 0; +} + +int fpu_test_19(void) +{ + enable_fp(); + return trapit(0, test19); +} + +#define LT 8 +#define GT 4 +#define EQ 2 +#define UN 1 + +struct cmpvals { + unsigned long vala, valb; + unsigned long result; +} cmpvals[] = { + { 0x0000000000000000, 0x0000000000000000, EQ }, + { 0x8000000000000000, 0x0000000000000000, EQ }, + { 0x3ff0000000000000, 0x3ff0000000000000, EQ }, + { 0x3ff0000000000001, 0x3ff0000000000000, GT }, + { 0x3ff0000000000000, 0x3ff0000000000001, LT }, + { 0xbff0000000000000, 0x3ff0000000000000, LT }, + { 0x7ff0000000000000, 0x7ff0000000000000, EQ }, + { 0xfff0000000000000, 0x7ff0000000000000, LT }, + { 0x7ff8000000000000, 0x7ff0000000000000, UN }, + { 0xfff8000000000000, 0x7ff0000000000000, UN }, + { 0x0000000000000001, 0x0000000000000001, EQ }, + { 0x8000000000000001, 0x7ff0000000000000, LT }, + { 0xffffffffffffffff, 0x7ff0000000000000, UN }, + { 0xffffffffffffffff, 0xffffffffffffffff, UN }, +}; + +int test20(long arg) +{ + long i; + unsigned long cr; + struct cmpvals *vp = cmpvals; + + for (i = 0; i < sizeof(cmpvals) / sizeof(cmpvals[0]); ++i, ++vp) { + asm("lfd 6,0(%1); lfd 10,8(%1); fcmpu 7,6,10; mfcr %0" + : "=r" (cr) : "b" (&vp->vala) : "memory"); + cr &= 0xf; + if (cr != vp->result) { + print_hex(i, 2, " "); + print_hex(cr, 1, " "); + return i + 1; + } + } + return 0; +} + +int fpu_test_20(void) +{ + enable_fp(); + return trapit(0, test20); +} + int fail = 0; void do_test(int num, int (*test)(void)) @@ -1191,6 +1287,8 @@ int main(void) do_test(16, fpu_test_16); do_test(17, fpu_test_17); do_test(18, fpu_test_18); + do_test(19, fpu_test_19); + do_test(20, fpu_test_20); return fail; } diff --git a/tests/test_fpu.bin b/tests/test_fpu.bin index 572aad0ef8df74ffd3de84f0d0435c5bf1706b02..0f9e03a588b27413f4d3522e6be6362f86d9204d 100755 GIT binary patch delta 3674 zcmai03s93+7C!$^5`rQPk_RA<5D%a6KiGTWBvEsKM4)2+uoVW zIp;gyJ@>nh|Awy5xvsNZI)G(9Kxy^4@X|)IwXnLh8o)-_I>OcwwyxH>dT;t{&b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~iuHry{v!v#}^* zE7RP?Yzj|1Cx*D<^*Uw0tb9Up+X-oZly`)Cv=ndhjTEZ{*X~iqf(UZaq9T!4FEQ4@ z0ThneP+Jk3Ld%6?8@XO)te*oY9BV=yM@&M?g=1}~(}-np0EOF5RMj_(T_OaYEH%=> zZ=j{rOiz9beQ2zHIA3a@&-!5oP16|YWdrRTgAz1@W3UO0e+*jCL>J2R6iz)#@q? zQ&E$m2pRsJJU^CxyA4e=F2=;P=x*6R+24PQmhWaSFuLq&KJWoB0?o<%I zDmSU8(QWz;{)dEA6<*2rkYdRY*PuHMZ&)(byV1)ZhksZMVkf#+Va$@Q9zbtk0_v>> z@dCOvu+Ew;-a_vZ_wpo>kmes58{iE+7Sn)ddRN%CFoslptFC%DJo+`r!D`*sjFjEz zZp8mxNt}+d2Gxz2<0_<7RD!lbB@Saa1<4hw3$$uX{`cN_`3$lUJA@ct$mMZV8L>fV zuc%WWLNDPOd|hGE4WK)GjWLISjI}WmHb(0}SDBeRJy3 diff --git a/tests/test_fpu.console_out b/tests/test_fpu.console_out index a5c08ea..aea206f 100644 --- a/tests/test_fpu.console_out +++ b/tests/test_fpu.console_out @@ -16,3 +16,5 @@ test 15:PASS test 16:PASS test 17:PASS test 18:PASS +test 19:PASS +test 20:PASS -- 2.30.2