diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2015-10-30 15:36:39 -0400 |
---|---|---|
committer | Nicolas Pitre <nicolas.pitre@linaro.org> | 2015-11-16 14:42:08 -0500 |
commit | 461a5e51060c93f5844113f4be9dba513cc92830 (patch) | |
tree | f02ce68a22937ce0b8d2c609e77bccc02c86455a /.mailmap | |
parent | 911918aa7ef6f868c135505b0015e42072c54682 (diff) | |
download | linux-461a5e51060c93f5844113f4be9dba513cc92830.tar.bz2 |
do_div(): generic optimization for constant divisor on 32-bit machines
64-by-32-bit divisions are prominent in the kernel, even on 32-bit
machines. Luckily, many of them use a constant divisor that allows
for a much faster multiplication by the divisor's reciprocal.
The compiler already performs this optimization when compiling a 32-by-32
division with a constant divisor. Unfortunately, on 32-bit machines, gcc
does not optimize 64-by-32 divisions in that case, except for constant
divisors that happen to be a power of 2.
Let's avoid the slow path whenever the divisor is constant by manually
computing the reciprocal ourselves and performing the multiplication
inline. In most cases, this improves performance of 64-by-32 divisions
by about two orders of magnitude compared to the __div64_32() fallback,
especially on architectures lacking a native div instruction.
The algorithm used here comes from the existing ARM code.
The __div64_const32_is_OK macro can be predefined by architectures to
disable this optimization in some cases. For example, some ancient gcc
version on ARM would crash with an ICE when fed this code.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Diffstat (limited to '.mailmap')
0 files changed, 0 insertions, 0 deletions