From edd2d136a062a9fe06b0c7dd506e203e6bb80081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 19 May 2013 18:48:10 +0000 Subject: [PATCH] unrolled modulo in {div|divu}_64x32_rem() and {mod|modu}_64x32() since it is apparently faster - this also gets rid of a duplicated div operation in {div|divu}_64x32_rem() / div*_64x32_rem() now call div*_64x32() (nw) --- src/emu/eminline.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/emu/eminline.h b/src/emu/eminline.h index 992a5039cf9..b6ae6fce342 100644 --- a/src/emu/eminline.h +++ b/src/emu/eminline.h @@ -155,8 +155,9 @@ INLINE UINT32 divu_64x32(UINT64 a, UINT32 b) #ifndef div_64x32_rem INLINE INT32 div_64x32_rem(INT64 a, INT32 b, INT32 *remainder) { - *remainder = a % (INT64)b; - return a / (INT64)b; + INT32 res = div_64x32(a, b); + *remainder = a - ((INT64)b * res); + return res; } #endif @@ -170,8 +171,9 @@ INLINE INT32 div_64x32_rem(INT64 a, INT32 b, INT32 *remainder) #ifndef divu_64x32_rem INLINE UINT32 divu_64x32_rem(UINT64 a, UINT32 b, UINT32 *remainder) { - *remainder = a % (UINT64)b; - return a / (UINT64)b; + UINT32 res = divu_64x32(a, b); + *remainder = a - ((UINT64)b * res); + return res; } #endif @@ -212,7 +214,7 @@ INLINE UINT32 divu_32x32_shift(UINT32 a, UINT32 b, UINT8 shift) #ifndef mod_64x32 INLINE INT32 mod_64x32(INT64 a, INT32 b) { - return a % (INT64)b; + return a - (b * div_64x32(a, b)); } #endif @@ -225,7 +227,7 @@ INLINE INT32 mod_64x32(INT64 a, INT32 b) #ifndef modu_64x32 INLINE UINT32 modu_64x32(UINT64 a, UINT32 b) { - return a % (UINT64)b; + return a - (b * divu_64x32(a, b)); } #endif