aarch64: Preserve mem info on change of base for ldp/stp [PR114674]
commit74690ff96b263b8609639b7fbc5d6afd3f19cb98
authorAlex Coplan <alex.coplan@arm.com>
Wed, 10 Apr 2024 15:30:36 +0000 (10 16:30 +0100)
committerAlex Coplan <alex.coplan@arm.com>
Tue, 7 May 2024 13:42:08 +0000 (7 14:42 +0100)
treef14b2facc06aa95c8adbe49282498e1d3a1572b7
parentbf10f0db20db1598157505b373098bc93c66b915
aarch64: Preserve mem info on change of base for ldp/stp [PR114674]

The ldp/stp fusion pass can change the base of an access so that the two
accesses end up using a common base register.  So far we have been using
adjust_address_nv to do this, but this means that we don't preserve
other properties of the mem we're replacing.  It seems better to use
replace_equiv_address_nv, as this will preserve e.g. the MEM_ALIGN of the
mem whose address we're changing.

The PR shows that by adjusting the other mem we lose alignment
information about the original access and therefore end up rejecting an
otherwise viable pair when --param=aarch64-stp-policy=aligned is passed.
This patch fixes that by using replace_equiv_address_nv instead.

Notably this is the same approach as taken by
aarch64_check_consecutive_mems when a change of base is required, so
this at least makes things more consistent between the ldp fusion pass
and the peepholes.

gcc/ChangeLog:

PR target/114674
* config/aarch64/aarch64-ldp-fusion.cc (ldp_bb_info::fuse_pair):
Use replace_equiv_address_nv on a change of base instead of
adjust_address_nv on the other access.

gcc/testsuite/ChangeLog:

PR target/114674
* gcc.target/aarch64/pr114674.c: New test.
gcc/config/aarch64/aarch64-ldp-fusion.cc
gcc/testsuite/gcc.target/aarch64/pr114674.c [new file with mode: 0644]