| 1 |
/* For some targets we end up vectorizing the below loop such that the `sp` |
| 2 |
single integer is loaded into a 4 integer vector. |
| 3 |
While the writes are all safe, without 2 scalar loops being peeled into the |
| 4 |
epilogue we would read past the end of the 31 integer array. This happens |
| 5 |
because we load a 4 integer chunk to only use the first integer and |
| 6 |
increment by 2 integers at a time, hence the last load needs s[30-33] and |
| 7 |
the penultimate load needs s[28-31]. |
| 8 |
This testcase ensures that we do not crash due to that behaviour. */ |
| 9 |
/* { dg-do run } */ |
| 10 |
/* { dg-options "-std=gnu17 -O2 -ftree-vectorize -fno-vect-cost-model --param vect-partial-vector-usage=2 -mavx512bw -mprefer-vector-width=512" } */ |
| 11 |
/* { dg-require-effective-target mmap } */ |
| 12 |
#include <sys/mman.h> |
| 13 |
#include <stdio.h> |
| 14 |
|
| 15 |
#define MMAP_SIZE 0x20000 |
| 16 |
#define ADDRESS 0x1122000000 |
| 17 |
|
| 18 |
#define MB_BLOCK_SIZE 16 |
| 19 |
#define VERT_PRED_16 0 |
| 20 |
#define HOR_PRED_16 1 |
| 21 |
#define DC_PRED_16 2 |
| 22 |
int *sptr; |
| 23 |
extern void intrapred_luma_16x16(); |
| 24 |
unsigned short mprr_2[5][16][16]; |
| 25 |
void initialise_s(int *s) { } |
| 26 |
int main_1() { |
| 27 |
void *s_mapping; |
| 28 |
void *end_s; |
| 29 |
s_mapping = mmap ((void *)ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, |
| 30 |
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| 31 |
if (s_mapping == MAP_FAILED) |
| 32 |
{ |
| 33 |
perror ("mmap"); |
| 34 |
return 1; |
| 35 |
} |
| 36 |
end_s = (s_mapping + MMAP_SIZE); |
| 37 |
sptr = (int*)(end_s - sizeof(int[31])); |
| 38 |
intrapred_luma_16x16(sptr); |
| 39 |
return 0; |
| 40 |
} |
| 41 |
|
| 42 |
void intrapred_luma_16x16(int * restrict sp) { |
| 43 |
for (int j=0; j < MB_BLOCK_SIZE; j++) |
| 44 |
{ |
| 45 |
mprr_2[VERT_PRED_16][j][0]=sp[j*2]; |
| 46 |
mprr_2[VERT_PRED_16][j][1]=sp[j*2]; |
| 47 |
mprr_2[VERT_PRED_16][j][2]=sp[j*2]; |
| 48 |
mprr_2[VERT_PRED_16][j][3]=sp[j*2]; |
| 49 |
mprr_2[VERT_PRED_16][j][4]=sp[j*2]; |
| 50 |
mprr_2[VERT_PRED_16][j][5]=sp[j*2]; |
| 51 |
mprr_2[VERT_PRED_16][j][6]=sp[j*2]; |
| 52 |
mprr_2[VERT_PRED_16][j][7]=sp[j*2]; |
| 53 |
mprr_2[VERT_PRED_16][j][8]=sp[j*2]; |
| 54 |
mprr_2[VERT_PRED_16][j][9]=sp[j*2]; |
| 55 |
mprr_2[VERT_PRED_16][j][10]=sp[j*2]; |
| 56 |
mprr_2[VERT_PRED_16][j][11]=sp[j*2]; |
| 57 |
mprr_2[VERT_PRED_16][j][12]=sp[j*2]; |
| 58 |
mprr_2[VERT_PRED_16][j][13]=sp[j*2]; |
| 59 |
mprr_2[VERT_PRED_16][j][14]=sp[j*2]; |
| 60 |
mprr_2[VERT_PRED_16][j][15]=sp[j*2]; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
#define DO_TEST main_1 |
| 65 |
#include "avx512-check.h" |