| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3" } */ |
| 3 |
|
| 4 |
#pragma GCC target "+nosve" |
| 5 |
|
| 6 |
typedef int __attribute__ ((mode (SI))) int32_t; |
| 7 |
typedef int __attribute__ ((mode (DI))) int64_t; |
| 8 |
typedef unsigned __attribute__ ((mode (SI))) size_t; |
| 9 |
typedef unsigned __attribute__ ((mode (SI))) uint32_t; |
| 10 |
typedef unsigned __attribute__ ((mode (DI))) uint64_t; |
| 11 |
|
| 12 |
/* Ensure we use the signed/unsigned extend vectorized add and sub |
| 13 |
instructions. */ |
| 14 |
#define N 1024 |
| 15 |
|
| 16 |
int32_t a[N]; |
| 17 |
int64_t c[N]; |
| 18 |
int64_t d[N]; |
| 19 |
uint32_t ua[N]; |
| 20 |
uint64_t uc[N]; |
| 21 |
uint64_t ud[N]; |
| 22 |
|
| 23 |
void |
| 24 |
add () |
| 25 |
{ |
| 26 |
for (size_t i = 0; i < N; i++) |
| 27 |
d[i] = a[i] + c[i]; |
| 28 |
} |
| 29 |
/* { dg-final { scan-assembler-times "\[ \t\]saddw2\[ \t\]+" 1 } } */ |
| 30 |
/* { dg-final { scan-assembler-times "\[ \t\]saddw\[ \t\]+" 1 } } */ |
| 31 |
|
| 32 |
void |
| 33 |
subtract () |
| 34 |
{ |
| 35 |
for (size_t i = 0; i < N; i++) |
| 36 |
d[i] = c[i] - a[i]; |
| 37 |
} |
| 38 |
/* { dg-final { scan-assembler-times "\[ \t\]ssubw2\[ \t\]+" 1 } } */ |
| 39 |
/* { dg-final { scan-assembler-times "\[ \t\]ssubw\[ \t\]+" 1 } } */ |
| 40 |
|
| 41 |
void |
| 42 |
uadd () |
| 43 |
{ |
| 44 |
for (size_t i = 0; i < N; i++) |
| 45 |
ud[i] = ua[i] + uc[i]; |
| 46 |
} |
| 47 |
/* { dg-final { scan-assembler-times "\[ \t\]uaddw2\[ \t\]+" 1 } } */ |
| 48 |
/* { dg-final { scan-assembler-times "\[ \t\]uaddw\[ \t\]+" 1 } } */ |
| 49 |
|
| 50 |
void |
| 51 |
usubtract () |
| 52 |
{ |
| 53 |
for (size_t i = 0; i < N; i++) |
| 54 |
ud[i] = uc[i] - ua[i]; |
| 55 |
} |
| 56 |
/* { dg-final { scan-assembler-times "\[ \t\]usubw2\[ \t\]+" 1 } } */ |
| 57 |
/* { dg-final { scan-assembler-times "\[ \t\]usubw\[ \t\]+" 1 } } */ |