https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118103

--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <pa...@gcc.gnu.org>:

https://gcc.gnu.org/g:1c8e6734d2dd3a6236d94c6e4e0c6780f35ede9f

commit r15-7421-g1c8e6734d2dd3a6236d94c6e4e0c6780f35ede9f
Author: Pan Li <pan2...@intel.com>
Date:   Fri Feb 7 14:21:35 2025 +0800

    RISC-V: Make VXRM as global register [PR118103]

    Inspired by PR118103, the VXRM register should be treated almost the
    same as the FRM register, aka cooperatively-managed global register.
    Thus, add the VXRM to global_regs to avoid the elimination by the
    late-combine pass.

    For example as below code:

      21   â
      22   â void compute ()
      23   â {
      24   â   size_t vl = __riscv_vsetvl_e16m1 (N);
      25   â   vuint16m1_t va = __riscv_vle16_v_u16m1 (a, vl);
      26   â   vuint16m1_t vb = __riscv_vle16_v_u16m1 (b, vl);
      27   â   vuint16m1_t vc = __riscv_vaaddu_vv_u16m1 (va, vb,
__RISCV_VXRM_RDN, vl);
      28   â
      29   â   __riscv_vse16_v_u16m1 (c, vc, vl);
      30   â }
      31   â
      32   â int main ()
      33   â {
      34   â   initialize ();
      35   â   compute();
      36   â
      37   â   return 0;
      38   â }

    After compile with -march=rv64gcv -O3, we will have:

      30   â compute:
      31   â     csrwi   vxrm,2
      32   â     lui a3,%hi(a)
      33   â     lui a4,%hi(b)
      34   â     addi    a4,a4,%lo(b)
      35   â     vsetivli    zero,4,e16,m1,ta,ma
      36   â     addi    a3,a3,%lo(a)
      37   â     vle16.v v2,0(a4)
      38   â     vle16.v v1,0(a3)
      39   â     lui a4,%hi(c)
      40   â     addi    a4,a4,%lo(c)
      41   â     vaaddu.vv   v1,v1,v2
      42   â     vse16.v v1,0(a4)
      43   â     ret
      44   â     .size   compute, .-compute
      45   â     .section    .text.startup,"ax",@progbits
      46   â     .align  1
      47   â     .globl  main
      48   â     .type   main, @function
      49   â main:
           |     // csrwi   vxrm,2 deleted after inline
      50   â     addi    sp,sp,-16
      51   â     sd  ra,8(sp)
      52   â     call    initialize
      53   â     lui a3,%hi(a)
      54   â     lui a4,%hi(b)
      55   â     vsetivli    zero,4,e16,m1,ta,ma
      56   â     addi    a4,a4,%lo(b)
      57   â     addi    a3,a3,%lo(a)
      58   â     vle16.v v2,0(a4)
      59   â     vle16.v v1,0(a3)
      60   â     lui a4,%hi(c)
      61   â     addi    a4,a4,%lo(c)
      62   â     li  a0,0
      63   â     vaaddu.vv   v1,v1,v2

    The below test suites are passed for this patch.
    * The rv64gcv fully regression test.

            PR target/118103

    gcc/ChangeLog:

            * config/riscv/riscv.cc (riscv_conditional_register_usage): Add
            the VXRM as the global_regs.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/base/pr118103-2.c: New test.
            * gcc.target/riscv/rvv/base/pr118103-run-2.c: New test.

    Signed-off-by: Pan Li <pan2...@intel.com>

Reply via email to