drm/panic: reconsider manual div10 for 32-bit ARM implementation in drm_panic_qr.rs
A message that is not in the archive (sent off-list or not yet received): 69c9da12-4895-414e-85e7-5d7c4e7bab7c@Spark
Hi,
while looking at drivers/gpu/drm/drm_panic_qr.rs, I noticed that div10() uses special manual implementation for 32-bit ARM. As far as I understand, this was introduced due to older LLVM behavior, where 64-bit division on 32-bit targets could lower into a call to __aeabi_uldivmod, which in this context could lead to a panic.
Reference:
https://github.com/MatthewCroughan/linux/commit/33429daec773809c01be492b46a6210ab1473851
However, starting from rustc 1.70.0 (and corresponding LLVM versions), this no longer seems to be an issue. The compiler now lowers constant division by 10 into a multiplication + shift sequence, avoiding runtime helper calls.
Additionally, the generated code appears to be at least as efficient, if not better, than the current manual implementation.
Godbolt proof:
https://godbolt.org/z/fonv1MEhT
Given this, I was wondering whether it makes sense to remove the platform-specific manual division path, and rely on the compiler for optimal code generation.
Thanks!