On 6/5/25 6:04 PM, Vineet Gupta wrote:
Changes since v1:
- NFC change to commitlog and drop test case for PR/119164
As described in prior patches of this series, RM manipulation could require
save/restore around calls (not in the caller-saved sense) but to retain
the global semantics. To that effect the current implementation requires
a mode switch state transition from DYN_CALL to DYN after a call_insn.
Defering/delaying this could lead to unncessary final transitions leading
to extraenous FRM save/restores.
However the current back checking of call_insn was too coarse-grained.
It used prev_nonnote_nondebug_insn_bb () which implies current insn to
be in the same BB as the call_insn, which need not always be true.
The problem is not with the API, but the use thereof.
Fix this by tracking call_insn more explicitly in TARGET_MODE_NEEDED.
- On seeing a call_insn, record a "call note".
- On subsequent insns if a "call note" is seen, do the needed state switch
and clear the note.
- Remove the old BB based search.
The number of FRM read/writes across SPEC2017 -Ofast -mrv64gcv improves.
Before After
------------- ---------------
frrm fsrmi fsrm frrm fsrmi frrm
perlbench_r 17 0 1 17 0 1
cpugcc_r 11 0 0 11 0 0
bwaves_r 16 0 1 16 0 1
mcf_r 11 0 0 11 0 0
cactusBSSN_r 19 0 1 19 0 1
namd_r 14 0 1 14 0 1
parest_r 24 0 1 24 0 1
povray_r 26 1 6 26 1 6
lbm_r 6 0 0 6 0 0
omnetpp_r 17 0 1 17 0 1
wrf_r 1268 13 1603 613 13 82
cpuxalan_r 17 0 1 17 0 1
ldecod_r 11 0 0 11 0 0
x264_r 11 0 0 11 0 0
blender_r 61 12 42 39 12 16
cam4_r 45 13 20 40 13 17
deepsjeng_r 11 0 0 11 0 0
imagick_r 132 16 25 33 16 18
leela_r 12 0 0 12 0 0
nab_r 13 0 1 13 0 1
exchange2_r 16 0 1 16 0 1
fotonik3d_r 19 0 1 19 0 1
roms_r 21 0 1 21 0 1
xz_r 6 0 0 6 0 0
----------------- --------------
1804 55 1707 1023 55 150
----------------- --------------
3566 1228
----------------- --------------
While this was a missed-optimization exercise, testing exposed a latent
bug as additional testsuite failure, captured as PR120203. The existing
test float-point-dynamic-frm-74.c was missing FRM save after a call.
| frrm a5
| fsrmi 1
|
| vfadd.vv v1,v8,v9
| fsrm a5
| beq a1,zero,.L2
|
| call normalize_vl_1
| frrm a5
|
| .L3:
| fsrmi 3
| vfadd.vv v8,v8,v9
| fsrm a5
| jr ra
|
| .L2:
| call normalize_vl_2
| frrm a5 <-- missing
| j .L3
PR target/120203
gcc/ChangeLog:
* config/riscv/riscv.cc (CFUN_IN_CALL): New macro.
(struct mode_switching_info): Add new field.
(riscv_frm_adjust_mode_after_call): Remove.
(riscv_frm_mode_needed): Track call_insn.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-74.c: Expect
an additional FRRM.
OK. Thanks for your patience.
Jeff