]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: frm/mode-switch: Reduce FRM restores on DYN transition [PR119164]
authorVineet Gupta <vineetg@rivosinc.com>
Sun, 8 Jun 2025 21:55:01 +0000 (14:55 -0700)
committerVineet Gupta <vineetg@rivosinc.com>
Sun, 8 Jun 2025 21:55:01 +0000 (14:55 -0700)
commit3c0f3b74bf6011b12fe12821ba6e1079309d9445
treeb5bacf6162eedd94f3575e446ab85ce75adc70b6
parent01b89455b09df72285a85e4fda1ff14fe4191d9e
RISC-V: frm/mode-switch: Reduce FRM restores on DYN transition [PR119164]

FRM mode switching state machine has DYN as default state which it also
fallsback to after transitioning to other states such as DYN_CALL.
Currently TARGET_MODE_EMIT generates a FRM restore on any transition to
DYN leading to spurious/extraneous FRM restores.

Only do this if an interim static Rounding Mode was observed in the state
machine.

Fixes the extraneous FRM read/write in PR119164 (and also PR119832 w/o need
for TARGET_MODE_CONFLUENCE). Also reduces the number of FRM writes in
SPEC2017 -Ofast -mrv64gcv build significantly.

                   Before            After
              -------------      -------------
              frrm fsrmi fsrm   frrm fsrmi frrm
  perlbench_r   42    0    4      17    0    1
     cpugcc_r  167    0   17      11    0    0
     bwaves_r   16    0    1      16    0    1
        mcf_r   11    0    0      11    0    0
 cactusBSSN_r   76    0   27      19    0    1
       namd_r  119    0   63      14    0    1
     parest_r  168    0  114      24    0    1
     povray_r  123    1   17      26    1    6
        lbm_r    6    0    0       6    0    0
    omnetpp_r   17    0    1      17    0    1
        wrf_r 2287   13 1956    1268   13 1603
   cpuxalan_r   17    0    1      17    0    1
     ldecod_r   11    0    0      11    0    0
       x264_r   14    0    1      11    0    0
    blender_r  724   12  182      61   12   42
       cam4_r  324   13  169      45   13   20
  deepsjeng_r   11    0    0      11    0    0
    imagick_r  265   16   34     132   16   25
      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   20    0   11      19    0    1
       roms_r   33    0   23      21    0    1
         xz_r    6    0    0       6    0    0
             ---------------    --------------
              4498   55 2623    1804   55 1707
             ---------------    --------------
                        7176              3566
             ---------------    --------------

PR target/119164

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_emit_frm_mode_set): check
STATIC_FRM_P for transition to DYN.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr119164.c: New test.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/rvv/base/pr119164.c [new file with mode: 0644]