| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mstringop-strategy=unrolled_loop -mtune=nocona" } */ |
| 3 |
|
| 4 |
#define PATTERN 0xdeadbeef |
| 5 |
#define SIZE 32 |
| 6 |
|
| 7 |
struct S { int i; char str[SIZE]; int j; }; |
| 8 |
|
| 9 |
void __attribute__((noclone, noinline)) |
| 10 |
my_memcpy (char *, const char *, unsigned int); |
| 11 |
|
| 12 |
void |
| 13 |
my_memcpy (char *dst, const char *src, unsigned int len) |
| 14 |
{ |
| 15 |
if (len < 8) |
| 16 |
__builtin_abort (); |
| 17 |
|
| 18 |
__builtin_memcpy (dst, src, len); |
| 19 |
} |
| 20 |
|
| 21 |
int |
| 22 |
main (void) |
| 23 |
{ |
| 24 |
const char str[SIZE]= "1234567890123456789012345678901"; |
| 25 |
struct S *s = __builtin_malloc (sizeof (struct S)); |
| 26 |
|
| 27 |
s->j = PATTERN; |
| 28 |
my_memcpy (s->str, str, SIZE); |
| 29 |
if (s->j != PATTERN) |
| 30 |
__builtin_abort (); |
| 31 |
|
| 32 |
return 0; |
| 33 |
} |