| 1 |
/* Test to verify that overlapping memcpy with const sizes that are powers |
| 2 |
of two are folded into into the same code as memmove, but that they |
| 3 |
are diagnosed nonetheless. Whether a call is folded depends on |
| 4 |
the size of the copy, the alignment, and wheteber else the target |
| 5 |
might decide to consider. The test is only run on a small subset |
| 6 |
of targets where it's known to pass (see PR testsuite/83483). |
| 7 |
{ dg-do compile } |
| 8 |
{ dg-options "-O0 -Wrestrict -fdump-tree-optimized" } |
| 9 |
{ dg-skip-if "skip non-x86 targets" { ! { i?86-*-* x86_64-*-* } } } |
| 10 |
{ dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */ |
| 11 |
|
| 12 |
char a[32]; |
| 13 |
|
| 14 |
void fold_copy_2 (void) |
| 15 |
{ |
| 16 |
__builtin_memcpy (a + 1, a, 2); /* { dg-warning "\\\[-Wrestrict]" } */ |
| 17 |
} |
| 18 |
|
| 19 |
void fold_copy_4 (void) |
| 20 |
{ |
| 21 |
__builtin_memcpy (a + 2, a, 4); /* { dg-warning "\\\[-Wrestrict]" } */ |
| 22 |
} |
| 23 |
|
| 24 |
void fold_copy_8 (void) |
| 25 |
{ |
| 26 |
__builtin_memcpy (a + 3, a, 8); /* { dg-warning "\\\[-Wrestrict]" } */ |
| 27 |
} |
| 28 |
|
| 29 |
void fold_move_2 (void) |
| 30 |
{ |
| 31 |
__builtin_memmove (a + 1, a, 2); |
| 32 |
} |
| 33 |
|
| 34 |
void fold_move_4 (void) |
| 35 |
{ |
| 36 |
__builtin_memmove (a + 2, a, 4); |
| 37 |
} |
| 38 |
|
| 39 |
void fold_move_8 (void) |
| 40 |
{ |
| 41 |
__builtin_memmove (a + 3, a, 8); |
| 42 |
} |
| 43 |
|
| 44 |
/* { dg-final { scan-tree-dump-not "memcpy" "optimized" } } |
| 45 |
{ dg-final { scan-tree-dump-not "memmove" "optimized" } } */ |