ARM: vfp: Improve data types in vfp_estimate_div128to64()
Subsystems (2)
PATCH RESEND 1/1 ARM: vfp: Improve data types in vfp_estimate_div128to64()
The divisors mh and ml can both be u32 instead of u64.
Since do_div() implicitly casts the divisors from u64 to u32, changing their data types to u32 also removes the following Coccinelle warnings reported by do_div.cocci:
arch/arm/vfp/vfp.h:121:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. arch/arm/vfp/vfp.h:135:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
Use upper_32_bits() to compare 32-bit numbers instead of 64-bit numbers and to prevent the warning:
left shift count >= width of type [-Wshift-count-overflow]
Compile-tested only.
Signed-off-by Thorsten Blum <[email protected]>
--- arch/arm/vfp/vfp.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm/vfp/vfp.h +4 -3
@@ -109,12 +109,13 @@ static inline u64 vfp_hi64multiply64(u64 n, u64 m)static inline u64 vfp_estimate_div128to64 (u64 nh,u64 nl,u64 m) { -u64 mh, ml, remh, reml, termh, terml, z; +u64 remh, reml, termh, terml, z; +u32 mh, ml;if (nh >= m)return ~0ULL ; mh = m >>32 ; -if (mh <<32 <= nh) { +if (mh <=upper_32_bits (nh)) { z =0xffffffff00000000ULL ; }else { z = nh;
@@ -129,7 +130,7 @@ static inline u64 vfp_estimate_div128to64(u64 nh, u64 nl, u64 m)add128 (&remh, &reml, remh, reml, mh, ml); } remh = (remh <<32 ) | (reml >>32 ); -if (mh <<32 <= remh) { +if (mh <=upper_32_bits (remh)) { z |=0xffffffff ; }else {do_div (remh, mh);
Signature · 1 line
2.48.1