]> git.ipfire.org Git - thirdparty/gcc.git/commit
late-combine: Tighten register class check [PR108840]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 18 Feb 2025 11:00:57 +0000 (11:00 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 18 Feb 2025 11:00:57 +0000 (11:00 +0000)
commitc5752c1f01316ac26ec9cf8d171d68aea420a158
tree79ab1014fdfae07340e71ba3550e0c18ed9a20e4
parentfacdce9028060c8dc4340a38ae02fb071e16af08
late-combine: Tighten register class check [PR108840]

gcc.target/aarch64/pr108840.c has failed since r15-268-g9dbff9c05520
(which means that I really ought to have looked at it earlier).

The test wants us to fold an SImode AND into all shifts that use it.
This is something that late-combine is supposed to do, but:

(1) the pre-RA pass chickened out because of a register pressure check

(2) the post-RA pass can't handle it, because the shift uses are in
    QImode and the sets are in SImode

Both are things that would be good to fix.  But (1) is particularly
silly.  The constraints on the AND have "rk" for the destination
(so allowing the stack pointer) and "r" for the first source.
Including the stack pointer made the destination seem more permissive
than the source.

The intention was instead to check whether there are any
*allocatable* registers in the destination class that aren't
present in the source.

That's enough for all tests but the last one.  The last one still
fails because combine merges the final shift with the move into
the hard return register, giving an arithmetic instruction with
a hard register destination.  Pre-RA late-combine currently punts
on those, again due to register pressure concerns.  That too is
something I'd like to relax, but not for GCC 15.  In the interim,
the best thing seems to be to disable combine for the test.

gcc/
PR rtl-optimization/108840
* late-combine.cc (late_combine::check_register_pressure):
Take only allocatable registers into account when checking
the permissiveness of register classes.

gcc/testsuite/
PR rtl-optimization/108840
* gcc.target/aarch64/pr108840.c: Run at -O2 but disable combine.
gcc/late-combine.cc
gcc/testsuite/gcc.target/aarch64/pr108840.c