]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Assume alias conflict if common address reg changes [PR116783]
authorAlex Coplan <alex.coplan@arm.com>
Wed, 30 Oct 2024 13:46:12 +0000 (13:46 +0000)
committerAlex Coplan <alex.coplan@arm.com>
Wed, 30 Oct 2024 15:32:18 +0000 (15:32 +0000)
commit434483ac32a08d1f3608c26fe2da302f0e09d6a2
treef1841a62f444ab83d68974224c8350f5d326ad53
parent71a0cf699b6a2dc03abec53aeafab8b70db2bb07
aarch64: Assume alias conflict if common address reg changes [PR116783]

As the PR shows, pair fusion was tricking memory_modified_in_insn_p into
returning false when a common base register (in this case, x1) was
modified between the mem and the store insn.  This lead to wrong code as
the accesses really did alias.

To avoid this sort of problem, this patch avoids invoking RTL alias
analysis altogether (and assume an alias conflict) if the two insns to
be compared share a common address register R, and the insns see different
definitions of R (i.e. it was modified in between).

This is a backport (but not a straight cherry pick) of
r15-4518-gc0e54ce1999ccf2241f74c5188b11b92e5aedc1f.

gcc/ChangeLog:

PR rtl-optimization/116783
* config/aarch64/aarch64-ldp-fusion.cc
(def_walker::cand_addr_uses): New.
(def_walker::def_walker): Add parameter for candidate address
uses.
(def_walker::alias_conflict_p): Declare.
(def_walker::addr_reg_conflict_p): New.
(def_walker::conflict_p): New.
(store_walker::store_walker): Add parameter for candidate
address uses and pass to base ctor.
(store_walker::conflict_p): Rename to ...
(store_walker::alias_conflict_p): ... this.
(load_walker::load_walker): Add parameter for candidate
address uses and pass to base ctor.
(load_walker::conflict_p): Rename to ...
(load_walker::alias_conflict_p): ... this.
(ldp_bb_info::try_fuse_pair): Collect address register
uses for candidate insns and pass down to alias walkers.

gcc/testsuite/ChangeLog:

PR rtl-optimization/116783
* g++.dg/torture/pr116783.C: New test.
gcc/config/aarch64/aarch64-ldp-fusion.cc
gcc/testsuite/g++.dg/torture/pr116783.C [new file with mode: 0644]