ARM: Speed up __mesabi_uldiv for powers-of-two divisors.
* lib/mes/div.c (__mesabi_uldiv): Speed up division for powers-of-two divisors.
This commit is contained in:
parent
bfd6792d07
commit
10bcb3709b
|
@ -50,11 +50,32 @@ __mesabi_uldiv (unsigned long a, unsigned long b, unsigned long* remainder)
|
||||||
if (!remainder)
|
if (!remainder)
|
||||||
remainder = &tmp;
|
remainder = &tmp;
|
||||||
*remainder = 0;
|
*remainder = 0;
|
||||||
if (b == 1)
|
switch (b) {
|
||||||
|
case 64UL:
|
||||||
|
*remainder = a & 63UL;
|
||||||
|
return a >> 6UL;
|
||||||
|
case 32UL:
|
||||||
|
*remainder = a & 31UL;
|
||||||
|
return a >> 5UL;
|
||||||
|
case 16UL:
|
||||||
|
*remainder = a & 15UL;
|
||||||
|
return a >> 4UL;
|
||||||
|
case 8UL:
|
||||||
|
*remainder = a & 7UL;
|
||||||
|
return a >> 3UL;
|
||||||
|
case 4UL:
|
||||||
|
*remainder = a & 3UL;
|
||||||
|
return a >> 2UL;
|
||||||
|
case 2UL:
|
||||||
|
*remainder = a & 1UL;
|
||||||
|
return a >> 1UL;
|
||||||
|
case 1UL:
|
||||||
|
*remainder = 0;
|
||||||
return a;
|
return a;
|
||||||
else if (b == 0)
|
case 0UL:
|
||||||
__mesabi_div0();
|
__mesabi_div0();
|
||||||
else
|
return 0UL;
|
||||||
|
default:
|
||||||
{
|
{
|
||||||
unsigned long x;
|
unsigned long x;
|
||||||
for (x = 0; a >= b; a -= b)
|
for (x = 0; a >= b; a -= b)
|
||||||
|
@ -62,6 +83,7 @@ __mesabi_uldiv (unsigned long a, unsigned long b, unsigned long* remainder)
|
||||||
*remainder = a;
|
*remainder = a;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: Rounds towards zero.
|
/* Note: Rounds towards zero.
|
||||||
|
|
Loading…
Reference in a new issue