https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119007
Bug ID: 119007
Summary: RISC-V: The optimization ignored the side effects of
the rounding mode, resulting in incorrect results for
rvv
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: majin at gcc dot gnu.org
Target Milestone: ---
Here is a record for now, as there isn't a better way at the moment.
REF:
https://patchwork.sourceware.org/project/gcc/patch/[email protected]/
/* { dg-do run { target { riscv_v } } } */
/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -O2" } */
#include <riscv_vector.h>
int main ()
{
float data_store = 0;
int8_t mask = 1;
size_t vl = 1;
float data_load = 0.0;
_Float16 data_sub = 0.0;
vint8mf8_t mask_value = __riscv_vle8_v_i8mf8 (&mask, vl);
vbool64_t vmask = __riscv_vmseq_vx_i8mf8_b64 (mask_value, 1, vl);
vfloat32mf2_t vd_load = __riscv_vfmv_v_f_f32mf2 (0, __riscv_vsetvlmax_e32mf2
());
vfloat32mf2_t vreg_memory = __riscv_vle32_v_f32mf2_tu (vd_load, &data_load,
vl);
vfloat32mf2_t vreg = __riscv_vfwsub_wf_f32mf2_rm_tum (vmask, vreg_memory,
vreg_memory, data_sub, __RISCV_FRM_RDN, vl);
__riscv_vse32_v_f32mf2 (&data_store, vreg, vl);
__builtin_printf ("%f\n", data_store);
return 0;
}
/* { dg-output "-0.000000\\s+\n" } */