Commit fdd33254 by Martin Liska Committed by Jakub Jelinek

re PR middle-end/81657 (FAIL: gcc.dg/20050503-1.c scan-assembler-not call)

	PR middle-end/81657
	* expr.h (enum block_op_methods): Add BLOCK_OP_NO_LIBCALL_RET.
	* expr.c (emit_block_move_hints): Handle BLOCK_OP_NO_LIBCALL_RET.
	* builtins.c (expand_builtin_memory_copy_args): Use
	BLOCK_OP_NO_LIBCALL_RET method for mempcpy with non-ignored target,
	handle dest_addr == pc_rtx.

	* gcc.dg/string-opt-1.c: Remove bogus comment.  Expect a mempcpy
	call.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r259366
parent 6888a172
2018-04-13 Martin Liska <mliska@suse.cz>
Jakub Jelinek <jakub@redhat.com>
PR middle-end/81657
* expr.h (enum block_op_methods): Add BLOCK_OP_NO_LIBCALL_RET.
* expr.c (emit_block_move_hints): Handle BLOCK_OP_NO_LIBCALL_RET.
* builtins.c (expand_builtin_memory_copy_args): Use
BLOCK_OP_NO_LIBCALL_RET method for mempcpy with non-ignored target,
handle dest_addr == pc_rtx.
2018-04-12 Segher Boessenkool <segher@kernel.crashing.org> 2018-04-12 Segher Boessenkool <segher@kernel.crashing.org>
PR target/85291 PR target/85291
......
...@@ -3650,12 +3650,16 @@ expand_builtin_memory_copy_args (tree dest, tree src, tree len, ...@@ -3650,12 +3650,16 @@ expand_builtin_memory_copy_args (tree dest, tree src, tree len,
set_mem_align (src_mem, src_align); set_mem_align (src_mem, src_align);
/* Copy word part most expediently. */ /* Copy word part most expediently. */
dest_addr = emit_block_move_hints (dest_mem, src_mem, len_rtx, enum block_op_methods method = BLOCK_OP_NORMAL;
CALL_EXPR_TAILCALL (exp) if (CALL_EXPR_TAILCALL (exp) && (endp == 0 || target == const0_rtx))
&& (endp == 0 || target == const0_rtx) method = BLOCK_OP_TAILCALL;
? BLOCK_OP_TAILCALL : BLOCK_OP_NORMAL, if (endp == 1 && target != const0_rtx)
method = BLOCK_OP_NO_LIBCALL_RET;
dest_addr = emit_block_move_hints (dest_mem, src_mem, len_rtx, method,
expected_align, expected_size, expected_align, expected_size,
min_size, max_size, probable_max_size); min_size, max_size, probable_max_size);
if (dest_addr == pc_rtx)
return NULL_RTX;
if (dest_addr == 0) if (dest_addr == 0)
{ {
......
...@@ -1565,7 +1565,7 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, ...@@ -1565,7 +1565,7 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
unsigned HOST_WIDE_INT max_size, unsigned HOST_WIDE_INT max_size,
unsigned HOST_WIDE_INT probable_max_size) unsigned HOST_WIDE_INT probable_max_size)
{ {
bool may_use_call; int may_use_call;
rtx retval = 0; rtx retval = 0;
unsigned int align; unsigned int align;
...@@ -1577,7 +1577,7 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, ...@@ -1577,7 +1577,7 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
{ {
case BLOCK_OP_NORMAL: case BLOCK_OP_NORMAL:
case BLOCK_OP_TAILCALL: case BLOCK_OP_TAILCALL:
may_use_call = true; may_use_call = 1;
break; break;
case BLOCK_OP_CALL_PARM: case BLOCK_OP_CALL_PARM:
...@@ -1589,7 +1589,11 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, ...@@ -1589,7 +1589,11 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
break; break;
case BLOCK_OP_NO_LIBCALL: case BLOCK_OP_NO_LIBCALL:
may_use_call = false; may_use_call = 0;
break;
case BLOCK_OP_NO_LIBCALL_RET:
may_use_call = -1;
break; break;
default: default:
...@@ -1625,6 +1629,9 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method, ...@@ -1625,6 +1629,9 @@ emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
&& ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (x)) && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (x))
&& ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (y))) && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (y)))
{ {
if (may_use_call < 0)
return pc_rtx;
/* Since x and y are passed to a libcall, mark the corresponding /* Since x and y are passed to a libcall, mark the corresponding
tree EXPR as addressable. */ tree EXPR as addressable. */
tree y_expr = MEM_EXPR (y); tree y_expr = MEM_EXPR (y);
......
...@@ -100,7 +100,11 @@ enum block_op_methods ...@@ -100,7 +100,11 @@ enum block_op_methods
BLOCK_OP_NO_LIBCALL, BLOCK_OP_NO_LIBCALL,
BLOCK_OP_CALL_PARM, BLOCK_OP_CALL_PARM,
/* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */ /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */
BLOCK_OP_TAILCALL BLOCK_OP_TAILCALL,
/* Like BLOCK_OP_NO_LIBCALL, but instead of emitting a libcall return
pc_rtx to indicate nothing has been emitted and let the caller handle
it. */
BLOCK_OP_NO_LIBCALL_RET
}; };
typedef rtx (*by_pieces_constfn) (void *, HOST_WIDE_INT, scalar_int_mode); typedef rtx (*by_pieces_constfn) (void *, HOST_WIDE_INT, scalar_int_mode);
......
2018-04-13 Martin Liska <mliska@suse.cz>
Jakub Jelinek <jakub@redhat.com>
PR middle-end/81657
* gcc.dg/string-opt-1.c: Remove bogus comment. Expect a mempcpy
call.
2018-04-12 David Malcolm <dmalcolm@redhat.com> 2018-04-12 David Malcolm <dmalcolm@redhat.com>
PR c++/85385 PR c++/85385
......
/* Ensure mempcpy is "optimized" into memcpy followed by addition. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2" } */ /* { dg-options "-O2" } */
...@@ -48,5 +47,5 @@ main (void) ...@@ -48,5 +47,5 @@ main (void)
return 0; return 0;
} }
/* { dg-final { scan-assembler-not "\<mempcpy\>" } } */ /* { dg-final { scan-assembler "mempcpy" } } */
/* { dg-final { scan-assembler "memcpy" } } */ /* { 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