This patch fixes following ICE:
test.c: In function 'func':
test.c:37:24: internal compiler error: Segmentation fault
37 | vfloat16mf2_t vc = __riscv_vlmul_trunc_v_f16m1_f16mf2(vb);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The root cause is that vlmul_trunc has a null return value.
gimple_call <__riscv_vlmul_trunc_v_f16m1_f16mf2, NULL, vb_13>
^^^
Passed the rv64gcv_zvfh regression test.
Singed-off-by: Li Xu <xuli1@eswincomputing.com>
PR target/117286
gcc/ChangeLog:
* config/riscv/riscv-vector-builtins-bases.cc: Do not expand NULL return.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/pr117286.c: New test.
rtx expand (function_expander &e) const override
{
+ if (!e.target)
+ return NULL_RTX;
tree arg = CALL_EXPR_ARG (e.exp, 0);
rtx src = expand_normal (arg);
emit_move_insn (gen_lowpart (e.vector_mode (), e.target), src);
rtx expand (function_expander &e) const override
{
+ if (!e.target)
+ return NULL_RTX;
rtx src = expand_normal (CALL_EXPR_ARG (e.exp, 0));
emit_move_insn (e.target, gen_lowpart (GET_MODE (e.target), src));
return e.target;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -O1" } */
+
+#include <riscv_vector.h>
+_Float16 a[10];
+void func(){
+ int placeholder0 = 10;
+ _Float16* ptr_a = a;
+ for (size_t vl; placeholder0 > 0; placeholder0 -= vl){
+ vl = __riscv_vsetvl_e16m1(placeholder0);
+ vfloat16mf2_t va = __riscv_vle16_v_f16mf2(ptr_a, vl);
+ vfloat16m1_t vb = __riscv_vlmul_ext_v_f16mf2_f16m1(va);
+ vfloat16mf2_t vc = __riscv_vlmul_trunc_v_f16m1_f16mf2(vb);
+ ptr_a += vl;
+ }
+}