]> git.ipfire.org Git - thirdparty/gcc.git/commit
asf: Fix offset check in base reg initialization for big-endian targets
authorKonstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>
Tue, 3 Jun 2025 07:16:17 +0000 (09:16 +0200)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Tue, 15 Jul 2025 14:16:12 +0000 (16:16 +0200)
commit60e99b5703051115220ef2b186979d4c416de530
treeeba8bf810987a4335f4695e6fc7f74c0adc4bc56
parent6b76dfad9b2c80a43b2e775d0027ba4b636d6022
asf: Fix offset check in base reg initialization for big-endian targets

During the base register initialization, in the case that we are
eliminating the load instruction, we are using `offset == 0` in order
to find the store instruction that has the same offset as the
load. This would not work on big-endian targets where byte 0 would be
the MS byte.

This patch updates the condition to take into account the target's
endianness.

We are, also, removing the adjustment of the starting position for the
bitfield insertion, when BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN. This is
supposed to be handled inside `store_bit_field` and it's not needed
anymore after the offset fix.

Bootstrapped/regtested on AArch64 LE, x86_64 and PowerPC LE.

gcc/ChangeLog:

* avoid-store-forwarding.cc (generate_bit_insert_sequence):
Remove adjustment of bitfield insertion's starting position
when BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN.
(process_store_forwarding): Update offset check in base reg
initialization to take into account the target's endianness.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/avoid-store-forwarding-be.c: New test.
gcc/avoid-store-forwarding.cc
gcc/testsuite/gcc.target/aarch64/avoid-store-forwarding-be.c [new file with mode: 0644]