| 1 |
/* { dg-do run { target vect_cmdline_needed } } */ |
| 2 |
/* { dg-do compile { target { loongarch_sx && {! loongarch_sx_hw } } } } */ |
| 3 |
/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */ |
| 4 |
/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */ |
| 5 |
/* { dg-additional-options "-mlsx" { target { loongarch*-*-* } } } */ |
| 6 |
|
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
#define N 16 |
| 10 |
|
| 11 |
#if __INT_MAX__ == 32767 |
| 12 |
typedef char half_word; |
| 13 |
#elif __LONG_MAX__ == 2147483647 |
| 14 |
typedef short half_word; |
| 15 |
#else |
| 16 |
typedef int half_word; |
| 17 |
#endif |
| 18 |
|
| 19 |
half_word cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; |
| 20 |
|
| 21 |
int main () |
| 22 |
{ |
| 23 |
half_word ca[N]; |
| 24 |
int i; |
| 25 |
|
| 26 |
for (i = 0; i < N; i++) |
| 27 |
{ |
| 28 |
ca[i] = cb[i]; |
| 29 |
} |
| 30 |
|
| 31 |
/* check results: */ |
| 32 |
#pragma GCC novector |
| 33 |
for (i = 0; i < N; i++) |
| 34 |
{ |
| 35 |
if (ca[i] != cb[i]) |
| 36 |
abort (); |
| 37 |
} |
| 38 |
|
| 39 |
return 0; |
| 40 |
} |
| 41 |
|
| 42 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! { avr-*-* pru-*-* } } } } } */ |
| 43 |
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { target { ! { avr-*-* pru-*-* } } } } } */ |