| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-skip-if "Don't inline memset using neon instructions" { ! arm_tune_string_ops_prefer_neon } } */ |
| 3 |
/* { dg-options "-save-temps -O2 -fno-inline" } */ |
| 4 |
/* { dg-add-options "arm_neon" } */ |
| 5 |
|
| 6 |
#include <string.h> |
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
#define LEN (100) |
| 10 |
int a[LEN]; |
| 11 |
int b[LEN]; |
| 12 |
int c[LEN]; |
| 13 |
void |
| 14 |
foo1 (void) |
| 15 |
{ |
| 16 |
memset (a, -1, 8); |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
void |
| 21 |
foo2 (void) |
| 22 |
{ |
| 23 |
memset (b, 1, 12); |
| 24 |
return; |
| 25 |
} |
| 26 |
|
| 27 |
void |
| 28 |
foo3 (void) |
| 29 |
{ |
| 30 |
memset (c, 1, 13); |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
void |
| 35 |
check (signed char *arr, int idx, int len, int v) |
| 36 |
{ |
| 37 |
int i; |
| 38 |
for (i = 0; i < idx; i++) |
| 39 |
if (arr[i] != v) |
| 40 |
abort (); |
| 41 |
|
| 42 |
for (i = idx; i < len; i++) |
| 43 |
if (arr[i] != 0) |
| 44 |
abort (); |
| 45 |
} |
| 46 |
|
| 47 |
int |
| 48 |
main(void) |
| 49 |
{ |
| 50 |
int i; |
| 51 |
|
| 52 |
foo1 (); |
| 53 |
check ((signed char *)a, 8, sizeof (a), -1); |
| 54 |
|
| 55 |
foo2 (); |
| 56 |
check ((signed char *)b, 12, sizeof (b), 1); |
| 57 |
|
| 58 |
foo3 (); |
| 59 |
check ((signed char *)c, 13, sizeof (c), 1); |
| 60 |
|
| 61 |
return 0; |
| 62 |
} |
| 63 |
|
| 64 |
/* { dg-final { scan-assembler-not "bl?\[ \t\]+memset" { target { ! arm_thumb1_ok } } } } */ |
| 65 |
/* { dg-final { scan-assembler-times "vst1\.8" 1 { target { arm_little_endian && arm_neon } } } } */ |
| 66 |
/* { dg-final { scan-assembler "vstr" { target { arm_little_endian && arm_neon } } } } */ |