| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-additional-options "-O0 -std=gnu99" } */ |
| 3 |
/* We used to generate a separate riscv_read_vl () after the FoF load. |
| 4 |
In case of -O0 (or otherwise) it could happen that "g" wouldn't |
| 5 |
get a hard reg and we'd need to store it, clobbering VL. |
| 6 |
This leads to an infinite loop or a segfault. */ |
| 7 |
|
| 8 |
#include <riscv_vector.h> |
| 9 |
|
| 10 |
uint8_t a[1]; |
| 11 |
int16_t b[1]; |
| 12 |
|
| 13 |
int main () |
| 14 |
{ |
| 15 |
for (size_t c = 0, avl = 1; avl > 0;) |
| 16 |
{ |
| 17 |
size_t d = avl; |
| 18 |
vint16mf2_t g = __riscv_vle16ff_v_i16mf2 (&b[c], &d, d); |
| 19 |
avl -= d; |
| 20 |
c += d; // Segmentation fault |
| 21 |
} |
| 22 |
} |