diff options
author | Richard Guenther <rguenther@suse.de> | 2010-08-30 13:46:31 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-08-30 13:46:31 +0000 |
commit | 2e481a2ff50e75ef3b8efb6644b41a260f813d3a (patch) | |
tree | 8615e6c45a047e637c31d93acb54d8ebb695d522 /gcc | |
parent | 3727f43413cd6b5d708977fec7d21a010efccedd (diff) | |
download | gcc-2e481a2ff50e75ef3b8efb6644b41a260f813d3a.zip gcc-2e481a2ff50e75ef3b8efb6644b41a260f813d3a.tar.gz gcc-2e481a2ff50e75ef3b8efb6644b41a260f813d3a.tar.bz2 |
re PR middle-end/21602 (builtin memmove could be memcpy if src and dst don't alias)
2010-08-30 Richard Guenther <rguenther@suse.de>
PR tree-optimization/21602
* builtins.c (fold_builtin_memory_op): Fold memmove to memcpy
using points-to information.
From-SVN: r163646
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 21 |
2 files changed, 27 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f0e5b25..685c2f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-08-30 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/21602 + * builtins.c (fold_builtin_memory_op): Fold memmove to memcpy + using points-to information. + 2010-08-30 H.J. Lu <hongjiu.lu@intel.com> * config/linux.h (TARGET_HAS_SINCOS): Replace | with ||. diff --git a/gcc/builtins.c b/gcc/builtins.c index 6d755a1..e4e3f9c 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8467,6 +8467,27 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, return NULL_TREE; return build_call_expr_loc (loc, fn, 3, dest, src, len); } + + /* If the destination and source do not alias optimize into + memcpy as well. */ + if ((is_gimple_min_invariant (dest) + || TREE_CODE (dest) == SSA_NAME) + && (is_gimple_min_invariant (src) + || TREE_CODE (src) == SSA_NAME)) + { + ao_ref destr, srcr; + ao_ref_init_from_ptr_and_size (&destr, dest, len); + ao_ref_init_from_ptr_and_size (&srcr, src, len); + if (!refs_may_alias_p_1 (&destr, &srcr, false)) + { + tree fn; + fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + if (!fn) + return NULL_TREE; + return build_call_expr_loc (loc, fn, 3, dest, src, len); + } + } + return NULL_TREE; } |