[LIB]: div64_64 optimization
Minor optimization of div64_64. do_div() already does optimization for the case of 32 by 32 divide, so no need to do it here. Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c454673da7
commit
22b9a0a3a4
16
lib/div64.c
16
lib/div64.c
|
@ -61,20 +61,18 @@ EXPORT_SYMBOL(__div64_32);
|
||||||
/* 64bit divisor, dividend and result. dynamic precision */
|
/* 64bit divisor, dividend and result. dynamic precision */
|
||||||
uint64_t div64_64(uint64_t dividend, uint64_t divisor)
|
uint64_t div64_64(uint64_t dividend, uint64_t divisor)
|
||||||
{
|
{
|
||||||
uint32_t d = divisor;
|
uint32_t high, d;
|
||||||
|
|
||||||
if (divisor > 0xffffffffULL) {
|
high = divisor >> 32;
|
||||||
unsigned int shift = fls(divisor >> 32);
|
if (high) {
|
||||||
|
unsigned int shift = fls(high);
|
||||||
|
|
||||||
d = divisor >> shift;
|
d = divisor >> shift;
|
||||||
dividend >>= shift;
|
dividend >>= shift;
|
||||||
}
|
} else
|
||||||
|
d = divisor;
|
||||||
|
|
||||||
/* avoid 64 bit division if possible */
|
do_div(dividend, d);
|
||||||
if (dividend >> 32)
|
|
||||||
do_div(dividend, d);
|
|
||||||
else
|
|
||||||
dividend = (uint32_t) dividend / d;
|
|
||||||
|
|
||||||
return dividend;
|
return dividend;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue