diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2022-01-10 14:47:08 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2022-01-10 14:47:08 +0000 |
commit | 01f3e6a40e7202310abbeb41c345d325bd69554f (patch) | |
tree | 6d8f6b63a55b2760ea02c3cb0eccc5cf6fc86d58 /gcc/ira-costs.c | |
parent | 8e7a23728f66d2da88b47e34224410457fdefbf5 (diff) | |
download | gcc-01f3e6a40e7202310abbeb41c345d325bd69554f.zip gcc-01f3e6a40e7202310abbeb41c345d325bd69554f.tar.gz gcc-01f3e6a40e7202310abbeb41c345d325bd69554f.tar.bz2 |
ira: Consider modelling caller-save allocations as loop spills
If an allocno A in an inner loop L spans a call, a parent allocno AP
can choose to handle a call-clobbered/caller-saved hard register R
in one of two ways:
(1) save R before each call in L and restore R after each call
(2) spill R to memory throughout L
(2) can be cheaper than (1) in some cases, particularly if L does
not reference A.
Before the patch we always did (1). The patch adds support for
picking (2) instead, when it seems cheaper. It builds on the
earlier support for not propagating conflicts to parent allocnos.
gcc/
PR rtl-optimization/98782
* ira-int.h (ira_caller_save_cost): New function.
(ira_caller_save_loop_spill_p): Likewise.
* ira-build.c (ira_propagate_hard_reg_costs): Test whether it is
cheaper to spill a call-clobbered register throughout a loop rather
than spill it around each individual call. If so, treat all
call-clobbered registers as conflicts and...
(propagate_allocno_info): ...do not propagate call information
from the child to the parent.
* ira-color.c (move_spill_restore): Update accordingly.
* ira-costs.c (ira_tune_allocno_costs): Use ira_caller_save_cost.
gcc/testsuite/
* gcc.target/aarch64/reg-alloc-3.c: New test.
Diffstat (limited to 'gcc/ira-costs.c')
-rw-r--r-- | gcc/ira-costs.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index 280befc..cbb58d3 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -2308,7 +2308,7 @@ ira_tune_allocno_costs (void) { int j, n, regno; int cost, min_cost, *reg_costs; - enum reg_class aclass, rclass; + enum reg_class aclass; machine_mode mode; ira_allocno_t a; ira_allocno_iterator ai; @@ -2347,12 +2347,9 @@ ira_tune_allocno_costs (void) } if (skip_p) continue; - rclass = REGNO_REG_CLASS (regno); cost = 0; if (ira_need_caller_save_p (a, regno)) - cost += (ALLOCNO_CALL_FREQ (a) - * (ira_memory_move_cost[mode][rclass][0] - + ira_memory_move_cost[mode][rclass][1])); + cost += ira_caller_save_cost (a); #ifdef IRA_HARD_REGNO_ADD_COST_MULTIPLIER cost += ((ira_memory_move_cost[mode][rclass][0] + ira_memory_move_cost[mode][rclass][1]) |