changed: UInt::Div3_Normalize - faster now

git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@101 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2009-03-03 20:41:00 +00:00
parent 5b24101a83
commit e18201ba35
2 changed files with 21 additions and 19 deletions

View File

@ -1450,9 +1450,9 @@ public:
__asm__ __volatile__( __asm__ __volatile__(
"bsrl %1, %0 \n" "bsrl %1, %0 \n"
"jnz 1f \n" "jnz 1f \n"
"movl $-1, %0 \n" "movl $-1, %0 \n"
"1: \n" "1: \n"
: "=R" (result) : "=R" (result)
: "R" (x) : "R" (x)
@ -2627,23 +2627,25 @@ private:
*/ */
uint Div3_Normalize(UInt<value_size> & v, uint n, uint & d) uint Div3_Normalize(UInt<value_size> & v, uint n, uint & d)
{ {
uint c = 0; // v.table[n-1] is != 0
// !!!!!!!!! change uint bit = (uint)FindLeadingBitInWord(v.table[n-1]);
for( d = 0 ; (v.table[n-1] & TTMATH_UINT_HIGHEST_BIT) == 0 ; ++d ) uint move = (TTMATH_BITS_PER_UINT - bit - 1);
uint res = table[value_size-1];
d = move;
if( move > 0 )
{ {
// we can move the bits only to the 'n-1' index but at the moment v.Rcl(move, 0);
// we don't have such method Rcl(move, 0);
// maybe it's time to write it now? res = res >> (bit + 1);
v.Rcl(1, 0); }
else
c <<= 1; {
res = 0;
if( Rcl(1, 0) )
c += 1;
} }
return c; return res;
} }

View File

@ -826,9 +826,9 @@ namespace ttmath
__asm__ __volatile__( __asm__ __volatile__(
"bsrq %1, %0 \n" "bsrq %1, %0 \n"
"jnz 1f \n" "jnz 1f \n"
"movq $-1, %0 \n" "movq $-1, %0 \n"
"1: \n" "1: \n"
: "=R" (result) : "=R" (result)
: "R" (x) : "R" (x)