Commit 671a00ee by Martin Liska Committed by Martin Liska

Make mempcpy more optimal (PR middle-end/70140).

2017-08-01  Martin Liska  <mliska@suse.cz>

	PR middle-end/70140
	* gcc.dg/string-opt-1.c: Adjust test-case to scan for memcpy.
2017-08-01  Martin Liska  <mliska@suse.cz>

	PR middle-end/70140
	* builtins.c (expand_builtin_memcpy_args): Remove.
	(expand_builtin_memcpy): Call newly added function
	expand_builtin_memory_copy_args.
	(expand_builtin_memcpy_with_bounds): Likewise.
	(expand_builtin_mempcpy): Remove last argument.
	(expand_builtin_mempcpy_with_bounds): Likewise.
	(expand_builtin_memory_copy_args): New function created from
	expand_builtin_mempcpy_args with small modifications.
	(expand_builtin_mempcpy_args): Remove.
	(expand_builtin_stpcpy): Remove unused argument.
	(expand_builtin): Likewise.
	(expand_builtin_with_bounds): Likewise.

From-SVN: r250789
parent 7d3eecca
2017-08-01 Martin Liska <mliska@suse.cz>
PR middle-end/70140
* builtins.c (expand_builtin_memcpy_args): Remove.
(expand_builtin_memcpy): Call newly added function
expand_builtin_memory_copy_args.
(expand_builtin_memcpy_with_bounds): Likewise.
(expand_builtin_mempcpy): Remove last argument.
(expand_builtin_mempcpy_with_bounds): Likewise.
(expand_builtin_memory_copy_args): New function created from
expand_builtin_mempcpy_args with small modifications.
(expand_builtin_mempcpy_args): Remove.
(expand_builtin_stpcpy): Remove unused argument.
(expand_builtin): Likewise.
(expand_builtin_with_bounds): Likewise.
2017-08-01 Martin Liska <mliska@suse.cz>
Revert r250771
Make mempcpy more optimal (PR middle-end/70140).
......
2017-08-01 Martin Liska <mliska@suse.cz>
PR middle-end/70140
* gcc.dg/string-opt-1.c: Adjust test-case to scan for memcpy.
2017-08-01 Martin Liska <mliska@suse.cz>
Revert r250771
Make mempcpy more optimal (PR middle-end/70140).
......
/* Ensure mempcpy is not "optimized" into memcpy followed by addition. */
/* Ensure mempcpy is "optimized" into memcpy followed by addition. */
/* { dg-do compile } */
/* { dg-options "-O2" } */
void *
fn (char *x, char *y, int z)
char *buffer;
char *test;
#define SIZE 100
char *
__attribute__((noinline))
my_memcpy (char *d, char *s, unsigned l)
{
return __builtin_memcpy (d, s, l);
}
char *
__attribute__((noinline))
my_mempcpy (char *d, char *s, unsigned l)
{
return __builtin_mempcpy (d, s, l);
}
void
run_test (char *d, char *s, unsigned l)
{
return __builtin_mempcpy (x, y, z);
char *r = my_mempcpy (d, s, l);
if (r != d + l)
__builtin_abort ();
r = my_memcpy (d, s, l);
if (r != d)
__builtin_abort ();
}
int
main (void)
{
const char* const foo = "hello world";
unsigned l = __builtin_strlen (foo) + 1;
buffer = __builtin_malloc (SIZE);
__builtin_memcpy (buffer, foo, l);
test = __builtin_malloc (SIZE);
run_test (test, buffer, l);
return 0;
}
/* { dg-final { scan-assembler-not "memcpy" } } */
/* { dg-final { scan-assembler-not "\<mempcpy\>" } } */
/* { dg-final { scan-assembler "memcpy" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment