1 /* Ensure mempcpy is "optimized" into memcpy followed by addition. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2" } */
11 __attribute__((noinline
))
12 my_memcpy (char *d
, char *s
, unsigned l
)
14 return __builtin_memcpy (d
, s
, l
);
18 __attribute__((noinline
))
19 my_mempcpy (char *d
, char *s
, unsigned l
)
21 return __builtin_mempcpy (d
, s
, l
);
25 run_test (char *d
, char *s
, unsigned l
)
27 char *r
= my_mempcpy (d
, s
, l
);
31 r
= my_memcpy (d
, s
, l
);
39 const char* const foo
= "hello world";
40 unsigned l
= __builtin_strlen (foo
) + 1;
42 buffer
= __builtin_malloc (SIZE
);
43 __builtin_memcpy (buffer
, foo
, l
);
44 test
= __builtin_malloc (SIZE
);
46 run_test (test
, buffer
, l
);
51 /* { dg-final { scan-assembler-not "\<mempcpy\>" } } */
52 /* { dg-final { scan-assembler "memcpy" } } */