diff options
author | Martin Liska <mliska@suse.cz> | 2019-05-20 09:55:00 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-05-20 07:55:00 +0000 |
commit | db91c7cf3d97a169d4e1c463d87a9f2007c40761 (patch) | |
tree | 11aa3bde6da1520b48d1a2a0cbf8e580e67e0c11 /gcc/builtins.c | |
parent | 03105885b1502a971955908255c722df5be0dafd (diff) |
Come up with hook libc_has_fast_function (PR middle-end/90263).
2019-05-20 Martin Liska <mliska@suse.cz>
PR middle-end/90263
* builtins.c (expand_builtin_memory_copy_args): When having a
target with fast mempcpy implementation do now use memcpy.
* config/i386/i386.c (ix86_libc_has_fast_function): New.
(TARGET_LIBC_HAS_FAST_FUNCTION): Likewise.
* doc/tm.texi: Likewise.
* doc/tm.texi.in: Likewise.
* target.def:
* expr.c (emit_block_move_hints): Add 2 new arguments.
* expr.h (emit_block_move_hints): Bail out when libcall
to memcpy would be used.
2019-05-20 Martin Liska <mliska@suse.cz>
PR middle-end/90263
* gcc.c-torture/compile/pr90263.c: New test.
* lib/target-supports.exp: Add check_effective_target_glibc.
From-SVN: r271400
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 0456a9ef646..3f32754c4d3 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -3839,6 +3839,8 @@ expand_builtin_memory_copy_args (tree dest, tree src, tree len, unsigned HOST_WIDE_INT max_size; unsigned HOST_WIDE_INT probable_max_size; + bool is_move_done; + /* If DEST is not a pointer type, call the normal function. */ if (dest_align == 0) return NULL_RTX; @@ -3888,11 +3890,22 @@ expand_builtin_memory_copy_args (tree dest, tree src, tree len, if (CALL_EXPR_TAILCALL (exp) && (retmode == RETURN_BEGIN || target == const0_rtx)) method = BLOCK_OP_TAILCALL; - if (retmode == RETURN_END && target != const0_rtx) + bool use_mempcpy_call = (targetm.libc_has_fast_function (BUILT_IN_MEMPCPY) + && retmode == RETURN_END + && target != const0_rtx); + if (use_mempcpy_call) method = BLOCK_OP_NO_LIBCALL_RET; dest_addr = emit_block_move_hints (dest_mem, src_mem, len_rtx, method, expected_align, expected_size, - min_size, max_size, probable_max_size); + min_size, max_size, probable_max_size, + use_mempcpy_call, &is_move_done); + + /* Bail out when a mempcpy call would be expanded as libcall and when + we have a target that provides a fast implementation + of mempcpy routine. */ + if (!is_move_done) + return NULL_RTX; + if (dest_addr == pc_rtx) return NULL_RTX; |