Issue 148837
Summary [RISC-V] __attribute__((interrupt)) does not save vector registers
Labels new issue
Assignees
Reporter amitch1999
    Hi,

I played around a little with a code snippet I found online of a vector function that uses intrinsics,
and I noticed that if I add the `__attribute__((interrupt))` attribute to the function, llvm does not save the vector registers used inside the function
Although all vector registers (v0-31) all caller-saved by the ABI.
GCC 14/15 does save the vector registers used in the function.

[Link to godbolt comparison](https://godbolt.org/z/5x36Kfshh)

The snippet:
```
#include <riscv_vector.h>

extern const float *in;
extern size_t n;
extern float ret;


__attribute__((interrupt)) void reduce_max()
{
    size_t vlmax = __riscv_vsetvlmax_e32m1();
 vfloat32m1_t max_array = __riscv_vfmv_s_f_f32m1(in[0], vlmax);

    while (n > 0)
    {
        size_t vl = __riscv_vsetvl_e32m1(n);

 vfloat32m1_t vs2 = __riscv_vle32_v_f32m1(in, vl);
        max_array = __riscv_vfmax_vv_f32m1(max_array, vs2, vl);

        in += vl;
        n -= vl;
    }

    vfloat32m1_t reduce_max = __riscv_vfredmax_vs_f32m1_f32m1(max_array, max_array, vlmax);
    ret = __riscv_vfmv_f_s_f32m1_f32(reduce_max);
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to