| 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 |
int d[LEN]; |
| 14 |
void |
| 15 |
foo1 (void) |
| 16 |
{ |
| 17 |
memset (a, -1, 16); |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
void |
| 22 |
foo2 (void) |
| 23 |
{ |
| 24 |
memset (b, 1, 25); |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
void |
| 29 |
foo3 (void) |
| 30 |
{ |
| 31 |
memset (c, -1, 19); |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
void |
| 36 |
foo4 (void) |
| 37 |
{ |
| 38 |
memset (d, 1, 23); |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
void |
| 43 |
check (signed char *arr, int idx, int len, int v) |
| 44 |
{ |
| 45 |
int i; |
| 46 |
for (i = 0; i < idx; i++) |
| 47 |
if (arr[i] != v) |
| 48 |
abort (); |
| 49 |
|
| 50 |
for (i = idx; i < len; i++) |
| 51 |
if (arr[i] != 0) |
| 52 |
abort (); |
| 53 |
} |
| 54 |
|
| 55 |
int |
| 56 |
main(void) |
| 57 |
{ |
| 58 |
foo1 (); |
| 59 |
check ((signed char *)a, 16, sizeof (a), -1); |
| 60 |
|
| 61 |
foo2 (); |
| 62 |
check ((signed char *)b, 25, sizeof (b), 1); |
| 63 |
|
| 64 |
foo3 (); |
| 65 |
check ((signed char *)c, 19, sizeof (c), -1); |
| 66 |
|
| 67 |
foo4 (); |
| 68 |
check ((signed char *)d, 23, sizeof (d), 1); |
| 69 |
|
| 70 |
return 0; |
| 71 |
} |
| 72 |
|
| 73 |
/* { dg-final { scan-assembler-not "bl?\[ \t\]+memset" { target { arm_little_endian && arm_neon } } } } */ |
| 74 |
/* { dg-final { scan-assembler "vst1" { target { arm_little_endian && arm_neon } } } } */ |
| 75 |
/* { dg-final { scan-assembler-not "vstr" { target { arm_little_endian && arm_neon } } } } */ |
| 76 |
|