https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114017
Bug ID: 114017 Summary: RISC-V: wrong __riscv_v_intrinsic predefined macro value (14.x) Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: maksim.shabunin at gmail dot com Target Milestone: --- Recent master branch version defines wrong RVV intrinsics version macro. ### GCC version and predefined value ./riscv-gcc-master/bin/riscv64-unknown-linux-gnu-g++ --version riscv64-unknown-linux-gnu-g++ (g61ab046a327) 14.0.1 20240220 (experimental) ./riscv-gcc-master/bin/riscv64-unknown-linux-gnu-g++ -dM -E -march=rv64gcv - < /dev/null | grep riscv_v_intrin #define __riscv_v_intrinsic 11000 ### Description Predefined value must be at least v0.12 (12000) because this is what is actually supported by the compiler. Following snippet demonstrates the problem by calling intrinsic which has been modified in v0.12. Without workaround the first block will be used and will fail to compile because actual builtin intrinsic requires `vxrm` argument. ### Example of code #include <riscv_vector.h> int main() { vuint16m1_t val; size_t shift = 1; size_t vl = 8; vuint8mf2_t res; #define GCC_WORKAROUND (__GNUC__ == 14 && __riscv_v_intrinsic==11000) #if __riscv_v_intrinsic==11000 && !GCC_WORKAROUND #warning "RVV Intrinsics v0.11" res = __riscv_vnclipu(val, shift, vl); #endif #if __riscv_v_intrinsic==12000 || GCC_WORKAROUND #warning "RVV Intrinsics v0.12" const unsigned int vxrm = 0; res = __riscv_vnclipu(val, shift, vxrm, vl); #endif return 0; } ### Error shown without workaround rvv_snippet.cpp:16:26: error: no matching function for call to '__riscv_vnclipu(vuint16m1_t&, size_t&, size_t&)' 16 | res = __riscv_vnclipu(val, shift, vl); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ In file included from rvv_snippet.cpp:1: /work/chains/riscv-gcc-master/lib/gcc/riscv64-unknown-linux-gnu/14.0.1/include/riscv_vector.h:43:25: note: candidate: 'vuint8mf8_t __riscv_vnclipu(vuint16mf4_t, vuint8mf8_t, unsigned int, long unsigned int)' 43 | #pragma riscv intrinsic "vector" | ^~~~~~~~ /work/chains/riscv-gcc-master/lib/gcc/riscv64-unknown-linux-gnu/14.0.1/include/riscv_vector.h:43:25: note: candidate expects 4 arguments, 3 provided <...long list of candidates...>