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).
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-*-* } } */
14 void fold_copy_2 (void)
16 __builtin_memcpy (a
+ 1, a
, 2); /* { dg-warning "\\\[-Wrestrict]" } */
19 void fold_copy_4 (void)
21 __builtin_memcpy (a
+ 2, a
, 4); /* { dg-warning "\\\[-Wrestrict]" } */
24 void fold_copy_8 (void)
26 __builtin_memcpy (a
+ 3, a
, 8); /* { dg-warning "\\\[-Wrestrict]" } */
29 void fold_move_2 (void)
31 __builtin_memmove (a
+ 1, a
, 2);
34 void fold_move_4 (void)
36 __builtin_memmove (a
+ 2, a
, 4);
39 void fold_move_8 (void)
41 __builtin_memmove (a
+ 3, a
, 8);
44 /* { dg-final { scan-tree-dump-not "memcpy" "optimized" } }
45 { dg-final { scan-tree-dump-not "memmove" "optimized" } } */