From: John Hodge Date: Sun, 20 Jun 2010 10:01:52 +0000 (+0800) Subject: Division bug hidden, now only shows when 64-bit division is needed X-Git-Tag: rel0.06~135 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=05dcc886a503b09aeddaed02a063c2a87c39cd9a;p=tpg%2Facess2.git Division bug hidden, now only shows when 64-bit division is needed --- diff --git a/Usermode/Libraries/libgcc.so_src/libgcc.c b/Usermode/Libraries/libgcc.so_src/libgcc.c index 794c2091..53ea6432 100644 --- a/Usermode/Libraries/libgcc.so_src/libgcc.c +++ b/Usermode/Libraries/libgcc.so_src/libgcc.c @@ -51,10 +51,14 @@ uint64_t __udivdi3(uint64_t Num, uint64_t Den) if(Den == 0) __asm__ __volatile__ ("int $0x0"); // Common speedups + if(Num <= 0xFFFFFFFF && Den <= 0xFFFFFFFF) + return Num / Den; if(Den == 1) return Num; if(Den == 2) return Num >> 1; if(Den == 16) return Num >> 4; - + if(Num < Den) return 0; + if(Num == Den) return 1; + if(Num == Den*2) return 2; // Non-restoring division, from wikipedia // http://en.wikipedia.org/wiki/Division_(digital) @@ -103,6 +107,13 @@ uint64_t __umoddi3(uint64_t Num, uint64_t Den) return Num; #else if(Den == 0) __asm__ __volatile__ ("int $0"); // Call Div by Zero Error + + // Speedups + if(Num < Den) return Num; + if(Num == Den) return 0; + if(Num <= 0xFFFFFFFF && Den <= 0xFFFFFFFF) + return Num % Den; + // Speedups for common operations if(Den == 1) return 0; if(Den == 2) return Num & 0x01;