On 11/12/26 1:47 AM, Jin Ma wrote:
Implement TARGET_CALLEE_SAVE_COST and TARGET_FRAME_ALLOCATION_COST so
IRA weighs callee saves against spills at their marginal execution
cost: reusing an already-required save is free, completing an odd
save count is discounted by half the memory cost (the fusion-aware
scheduling keeps the pair adjacent), and the first spill of a
frameless leaf is charged the separate SP adjustment.
This is a first, deliberately simple attempt, posted as a draft to
collect suggestions on the approach. The model is unweighted and
knows nothing about emission; with more precise modeling (call and
spill frequency weighting, awareness of the final save layout) the
fusion characteristics of the target should translate into more
reliable gains.
Assisted-by: qwen3.8-max
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_ira_save_mask): New.
(riscv_frame_allocation_cost): New.
(riscv_callee_save_cost): New.
(TARGET_FRAME_ALLOCATION_COST, TARGET_CALLEE_SAVE_COST): Define.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/callee-save-cost-mempair.c: New test.
* gcc.target/riscv/callee-save-cost-fusion.c: New test.
Interesting. I like the basic idea. Obviously it needs to test that
load/store pair fusion is supported.
Does aarch64 do something similar and if so are we roughly following
what they did?
Jeff