]> git.itanic.dy.fi Git - linux-stable/commit
ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod
authorNick Desaulniers <ndesaulniers@google.com>
Tue, 11 Oct 2022 19:00:12 +0000 (20:00 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 7 Nov 2022 14:19:02 +0000 (14:19 +0000)
commit3220022038b9a3845eea762af85f1c5694b9f861
treeb3c9b404446b9295072b2fd453d8aff65fb5e92b
parente513ffd881055c17ccdcc50f279360e2e1bffb40
ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod

clang-15's ability to elide loops completely became more aggressive when
it can deduce how a variable is being updated in a loop. Counting down
one variable by an increment of another can be replaced by a modulo
operation.

For 64b variables on 32b ARM EABI targets, this can result in the
compiler generating calls to __aeabi_uldivmod, which it does for a do
while loop in float64_rem().

For the kernel, we'd generally prefer that developers not open code 64b
division via binary / operators and instead use the more explicit
helpers from div64.h. On arm-linux-gnuabi targets, failure to do so can
result in linkage failures due to undefined references to
__aeabi_uldivmod().

While developers can avoid open coding divisions on 64b variables, the
compiler doesn't know that the Linux kernel has a partial implementation
of a compiler runtime (--rtlib) to enforce this convention.

It's also undecidable for the compiler whether the code in question
would be faster to execute the loop vs elide it and do the 64b division.

While I actively avoid using the internal -mllvm command line flags, I
think we get better code than using barrier() here, which will force
reloads+spills in the loop for all toolchains.

Link: https://github.com/ClangBuiltLinux/linux/issues/1666
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
arch/arm/nwfpe/Makefile