https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116616
Bug ID: 116616
Summary: Linux kernel fails to build on aarch64 due to
r15-3256-g1c4b9826bd0d5a
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: pheeck at gcc dot gnu.org
Reporter: pheeck at gcc dot gnu.org
CC: jamborm at gcc dot gnu.org, mkuvyrkov at gcc dot gnu.org
Target Milestone: ---
Host: x86_64-linux
Target: aarch64-gnu-linux
Linux stable kernel (commit 88fac17500f4ea49c7bac136cf1b27e7b9980075) currently
fails linking when built with trunk GCC aarch64 crosscompiler.
linux/drivers/regulator/core.c:4637:(.text+0x5cd0): undefined reference to
`__popcountdi2'
This is probably because the exponential index transform in the switch
conversion pass inserts a call to __builtin_popcount which eventually becomes a
call to the __popcountdi2 libgcc function.
Exp index transform counts on the widening_mul pass to notice this pattern
tmp1 = __builtin_popcount (var)
tmp2 = tmp1 == 1
and either convert the builtin into an internal function call or convert the
whole pattern into (var ^ (var - 1)) > (var - 1). In case of
drivers/regulator/core.c, this doesn't happen. Other optimizations move the
tmp1 == 1 statement farther from the __builtin_popcount call before
widening_mul is run.
I'm currently working on a fix in which I modify exponential index transform to
generate (var ^ (var - 1)) > (var - 1) instead of __builtin_popcount (var) ==
1.