From 0883f01e66aee87a08b50f82bbccfa4cd03e95cc Mon Sep 17 00:00:00 2001 From: smf- Date: Wed, 21 Mar 2018 16:48:52 +0000 Subject: validity check: test all 32 results from count_leading_zeros() & count_leading_ones() [smf] --- src/emu/validity.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp index 0a3d87ea58b..5a74a100147 100644 --- a/src/emu/validity.cpp +++ b/src/emu/validity.cpp @@ -511,16 +511,18 @@ void validity_checker::validate_inlines() if (fabsf(recip_approx(100.0f) - 0.01f) > 0.0001f) osd_printf_error("Error testing recip_approx\n"); - testi32a = (testi32a & 0x0000ffff) | 0x400000; - if (count_leading_zeros(testi32a) != 9) - osd_printf_error("Error testing count_leading_zeros\n"); - if (count_leading_zeros(0) != 32) - osd_printf_error("Error testing count_leading_zeros\n"); - testi32a = (testi32a | 0xffff0000) & ~0x400000; - if (count_leading_ones(testi32a) != 9) - osd_printf_error("Error testing count_leading_ones\n"); - if (count_leading_ones(0xffffffff) != 32) - osd_printf_error("Error testing count_leading_ones\n"); + for (int i = 0; i <= 32; i++) + { + u32 t = i < 32 ? (1 << (31 - i) | testu32a >> i) : 0; + u8 resultu8 = count_leading_zeros(t); + if (resultu8 != i) + osd_printf_error("Error testing count_leading_zeros %08x=%02x (expected %02x)\n", t, resultu8, i); + + t ^= 0xffffffff; + resultu8 = count_leading_ones(t); + if (resultu8 != i) + osd_printf_error("Error testing count_leading_ones %08x=%02x (expected %02x)\n", t, resultu8, i); + } } -- cgit v1.2.3