aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Coplan <alex.coplan@arm.com>2024-01-05 12:25:00 +0000
committerAlex Coplan <alex.coplan@arm.com>2024-01-05 12:25:00 +0000
commit4b67ec7ff5b1aa9b3b70e9b58afc594b890abeb0 (patch)
treee4c03993e47726ae164139b364f036678ef7eae0
parente66dc37b299cac4171b1c5b90cf6b54388bd5bc5 (diff)
downloadgcc-4b67ec7ff5b1aa9b3b70e9b58afc594b890abeb0.zip
gcc-4b67ec7ff5b1aa9b3b70e9b58afc594b890abeb0.tar.gz
gcc-4b67ec7ff5b1aa9b3b70e9b58afc594b890abeb0.tar.bz2
aarch64: Further fix for throwing insns in ldp/stp pass [PR113217]
As the PR shows, the fix in r14-6916-g057dc349021660c40699fb5c98fd9cac8e168653 was not complete. That fix was enough to stop us trying to move throwing accesses above nondebug insns, but due to this code in try_fuse_pair: // Placement strategy: push loads down and pull stores up, this should // help register pressure by reducing live ranges. if (load_p) range.first = range.last; else range.last = range.first; we would still try to move stores up above any debug insns that occurred immediately after the previous nondebug insn. This patch fixes that by narrowing the move range in the case that the second access is throwing to exactly the range of that insn. Note that we still need the fix to latest_hazard_before mentioned above so as to ensure we select a suitable base and reject pairs if it isn't viable to form the pair at the end of the BB. gcc/ChangeLog: PR target/113217 * config/aarch64/aarch64-ldp-fusion.cc (ldp_bb_info::try_fuse_pair): If the second access can throw, narrow the move range to exactly that insn. gcc/testsuite/ChangeLog: PR target/113217 * g++.dg/pr113217.C: New test.
-rw-r--r--gcc/config/aarch64/aarch64-ldp-fusion.cc9
-rw-r--r--gcc/testsuite/g++.dg/pr113217.C15
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc
index 25f9b2d..2fe1b1d 100644
--- a/gcc/config/aarch64/aarch64-ldp-fusion.cc
+++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc
@@ -2195,6 +2195,15 @@ ldp_bb_info::try_fuse_pair (bool load_p, unsigned access_size,
if (base->hazards[0])
range.last = base->hazards[0]->prev_nondebug_insn ();
+ // If the second insn can throw, narrow the move range to exactly that insn.
+ // This prevents us trying to move the second insn from the end of the BB.
+ if (cfun->can_throw_non_call_exceptions
+ && find_reg_note (insns[1]->rtl (), REG_EH_REGION, NULL_RTX))
+ {
+ gcc_assert (range.includes (insns[1]));
+ range = insn_range_info (insns[1]);
+ }
+
// Placement strategy: push loads down and pull stores up, this should
// help register pressure by reducing live ranges.
if (load_p)
diff --git a/gcc/testsuite/g++.dg/pr113217.C b/gcc/testsuite/g++.dg/pr113217.C
new file mode 100644
index 0000000..ec86154
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr113217.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-O -g -fnon-call-exceptions" }
+struct _Vector_base {
+ int _M_end_of_storage;
+};
+struct vector : _Vector_base {
+ vector() : _Vector_base() {}
+ ~vector();
+};
+struct LoadGraph {
+ LoadGraph();
+ vector colors;
+ vector data_block;
+};
+LoadGraph::LoadGraph() {}