Update PATCH V2 for DYN in needed as below. https://gcc.gnu.org/pipermail/gcc-patches/2023-July/623543.html
Pan From: Li, Pan2 Sent: Tuesday, July 4, 2023 2:50 PM To: [email protected]; gcc-patches <[email protected]> Cc: Robin Dapp <[email protected]>; jeffreyalaw <[email protected]>; Wang, Yanzhang <[email protected]>; kito.cheng <[email protected]> Subject: RE: [PATCH v1] RISC-V: Fix one bug for floating-point static frm Thanks Juzhe, passed all the test of riscv.exp and rvv.exp, will commit it with the reverted one with the final approval. Pan From: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> Sent: Tuesday, July 4, 2023 1:53 PM To: Li, Pan2 <[email protected]<mailto:[email protected]>>; gcc-patches <[email protected]<mailto:[email protected]>> Cc: Robin Dapp <[email protected]<mailto:[email protected]>>; jeffreyalaw <[email protected]<mailto:[email protected]>>; Li, Pan2 <[email protected]<mailto:[email protected]>>; Wang, Yanzhang <[email protected]<mailto:[email protected]>>; kito.cheng <[email protected]<mailto:[email protected]>> Subject: Re: [PATCH v1] RISC-V: Fix one bug for floating-point static frm LGTM ________________________________ [email protected]<mailto:[email protected]> From: pan2.li<mailto:[email protected]> Date: 2023-07-04 13:50 To: gcc-patches<mailto:[email protected]> CC: juzhe.zhong<mailto:[email protected]>; rdapp.gcc<mailto:[email protected]>; jeffreyalaw<mailto:[email protected]>; pan2.li<mailto:[email protected]>; yanzhang.wang<mailto:[email protected]>; kito.cheng<mailto:[email protected]> Subject: [PATCH v1] RISC-V: Fix one bug for floating-point static frm From: Pan Li <[email protected]<mailto:[email protected]>> This patch would like to fix one bug to align below items of spec. 1. By default, the RVV floating-point will take dyn mode. 2. DYN is invalid in FRM register for RVV floating-point. When mode switching the function entry and exit, it will take DYN as the frm mode. Signed-off-by: Pan Li <[email protected]<mailto:[email protected]>> gcc/ChangeLog: * config/riscv/riscv.cc (riscv_emit_mode_set): Avoid emit insn when FRM_MODE_DYN. (riscv_mode_entry): Take FRM_MODE_DYN as entry mode. (riscv_mode_exit): Likewise for exit mode. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-frm-insert-6.c: New test. --- gcc/config/riscv/riscv.cc | 6 ++-- .../riscv/rvv/base/float-point-frm-insert-6.c | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index e4dc8115e69..f5fe910426e 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -7670,7 +7670,7 @@ riscv_emit_mode_set (int entity, int mode, int prev_mode, emit_insn (gen_vxrmsi (gen_int_mode (mode, SImode))); break; case RISCV_FRM: - if (mode != FRM_MODE_NONE && mode != prev_mode) + if (mode != FRM_MODE_DYN && mode != prev_mode) { rtx scaler = gen_reg_rtx (SImode); rtx imm = gen_int_mode (mode, SImode); @@ -7774,7 +7774,7 @@ riscv_mode_entry (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_NONE; + return FRM_MODE_DYN; default: gcc_unreachable (); } @@ -7791,7 +7791,7 @@ riscv_mode_exit (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_NONE; + return FRM_MODE_DYN; default: gcc_unreachable (); } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c new file mode 100644 index 00000000000..6d896e0953e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3 -Wno-psabi" } */ + +#include "riscv_vector.h" + +typedef float float32_t; + +vfloat32m1_t +test_riscv_vfadd_vv_f32m1_rm (vfloat32m1_t op1, vfloat32m1_t op2, size_t vl) { + return __riscv_vfadd_vv_f32m1_rm (op1, op2, 7, vl); +} + +vfloat32m1_t +test_vfadd_vv_f32m1_m_rm(vbool32_t mask, vfloat32m1_t op1, vfloat32m1_t op2, + size_t vl) { + return __riscv_vfadd_vv_f32m1_m_rm(mask, op1, op2, 7, vl); +} + +vfloat32m1_t +test_vfadd_vf_f32m1_rm(vfloat32m1_t op1, float32_t op2, size_t vl) { + return __riscv_vfadd_vf_f32m1_rm(op1, op2, 7, vl); +} + +vfloat32m1_t +test_vfadd_vf_f32m1_m_rm(vbool32_t mask, vfloat32m1_t op1, float32_t op2, + size_t vl) { + return __riscv_vfadd_vf_f32m1_m_rm(mask, op1, op2, 7, vl); +} + +/* { dg-final { scan-assembler-times {vfadd\.v[vf]\s+v[0-9]+,\s*v[0-9]+,\s*[fav]+[0-9]+} 4 } } */ +/* { dg-final { scan-assembler-not {fsrm\s+[ax][0-9]+,\s*[ax][0-9]+} } } */ -- 2.34.1
