version 1.26, 2007/05/09 07:12:59
|
version 1.27, 2007/06/30 20:28:55
|
Line 509 typedef UDCell UDWtype;
|
Line 509 typedef UDCell UDWtype;
|
|
|
#include "longlong.h" |
#include "longlong.h" |
|
|
|
#if defined(udiv_qrnnd) && !defined(__alpha) && UDIV_NEEDS_NORMALIZATION |
static Cell MAYBE_UNUSED nlz(UCell x) |
static Cell MAYBE_UNUSED nlz(UCell x) |
/* number of leading zeros, adapted from "Hacker's Delight" */ |
/* number of leading zeros, adapted from "Hacker's Delight" */ |
{ |
{ |
Line 520 static Cell MAYBE_UNUSED nlz(UCell x)
|
Line 521 static Cell MAYBE_UNUSED nlz(UCell x)
|
#if defined(count_leading_zeros) |
#if defined(count_leading_zeros) |
count_leading_zeros(n,x); |
count_leading_zeros(n,x); |
#else |
#else |
#warning "count_leading_zeros undefined (should not happen)" |
|
n = 0; |
n = 0; |
#if (SIZEOF_CHAR_P > 4) |
#if (SIZEOF_CHAR_P > 4) |
if (x <= 0xffffffff) {n+=32; x <<= 32;} |
if (x <= 0xffffffff) |
#error "this can't be correct" |
n+=32; |
|
else |
|
x >>= 32; |
#endif |
#endif |
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;} |
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;} |
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;} |
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;} |
Line 534 static Cell MAYBE_UNUSED nlz(UCell x)
|
Line 536 static Cell MAYBE_UNUSED nlz(UCell x)
|
#endif |
#endif |
return n; |
return n; |
} |
} |
|
#endif /*defined(udiv_qrnnd) && !defined(__alpha) && UDIV_NEEDS_NORMALIZATION*/ |
|
|
#if !defined(ASM_UM_SLASH_MOD) |
#if !defined(ASM_UM_SLASH_MOD) |
UDCell umdiv (UDCell u, UCell v) |
UDCell umdiv (UDCell u, UCell v) |
Line 541 UDCell umdiv (UDCell u, UCell v)
|
Line 544 UDCell umdiv (UDCell u, UCell v)
|
Return quotient in lo, remainder in hi. */ |
Return quotient in lo, remainder in hi. */ |
{ |
{ |
UDCell res; |
UDCell res; |
#if defined(udiv_qrnnd) |
#if defined(udiv_qrnnd) && !defined(__alpha) |
|
#if 0 |
|
This code is slower on an Alpha (timings with gcc-3.3.5): |
|
other this |
|
*/ 5205 ms 5741 ms |
|
*/mod 5167 ms 5717 ms |
|
fm/mod 5467 ms 5312 ms |
|
sm/rem 4734 ms 5278 ms |
|
um/mod 4490 ms 5020 ms |
|
m*/ 15557 ms 17151 ms |
|
#endif /* 0 */ |
UCell q,r,u0,u1; |
UCell q,r,u0,u1; |
UCell MAYBE_UNUSED lz; |
UCell MAYBE_UNUSED lz; |
|
|
Line 561 UDCell umdiv (UDCell u, UCell v)
|
Line 574 UDCell umdiv (UDCell u, UCell v)
|
r >>= lz; |
r >>= lz; |
#endif |
#endif |
vm_twoCell2ud(q,r,res); |
vm_twoCell2ud(q,r,res); |
#else /* !(defined(udiv_qrnnd) */ |
#else /* !(defined(udiv_qrnnd) && !defined(__alpha)) */ |
#warning "udiv_qrnnd undefined (should not happen)" |
|
/* simple restoring subtract-and-shift algorithm, might be faster on Alpha */ |
/* simple restoring subtract-and-shift algorithm, might be faster on Alpha */ |
int i = CELL_BITS, c = 0; |
int i = CELL_BITS, c = 0; |
UCell q = 0; |
UCell q = 0; |
Ucell h, l; |
UCell h, l; |
|
|
vm_ud2twoCell(u,l,h); |
vm_ud2twoCell(u,l,h); |
if (v==0) |
if (v==0) |
Line 589 UDCell umdiv (UDCell u, UCell v)
|
Line 601 UDCell umdiv (UDCell u, UCell v)
|
q <<= 1; |
q <<= 1; |
} |
} |
vm_twoCell2ud(q,h,res); |
vm_twoCell2ud(q,h,res); |
#endif /* !(defined(udiv_qrnnd) && */ |
#endif /* !(defined(udiv_qrnnd) && !defined(__alpha)) */ |
return res; |
return res; |
} |
} |
#endif |
#endif |