This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [4.5 PATCH] Improve memmove -> memcpy folding optimization
- From: Diego Novillo <dnovillo at google dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 19 Mar 2009 19:12:16 -0400
- Subject: Re: [4.5 PATCH] Improve memmove -> memcpy folding optimization
- References: <20090319070538.GC4831@tyan-ft48-01.lab.bos.redhat.com>
2009/3/19 Jakub Jelinek <jakub@redhat.com>:
> Hi!
>
> Using get_ref_base_and_extent and ranges_overlap_p we can sometimes prove
> what src and dest point to don't overlap and thus memmove with those
> arguments can be safely optimized into memcpy.
>
> Bootstrapped/regtested on x86_64-linux, ok for 4.5?
>
> 2009-03-18 ÂJakub Jelinek Â<jakub@redhat.com>
>
> Â Â Â Â* builtins.c (fold_builtin_memory_op): Optimize memmove
> Â Â Â Âinto memcpy if we can prove source and destination don't overlap.
>
> Â Â Â Â* gcc.dg/memmove-2.c: New test.
> Â Â Â Â* gcc.dg/memmove-3.c: New test.
OK for 4.5 with two minor formatting changes
> + Â Â Â Â if (!dest_align || !src_align)
> + Â Â Â Â Â return NULL_TREE;
> + Â Â Â Â if (readonly_data_expr (src)
> + Â Â Â Â Â Â || (host_integerp (len, 1)
> + Â Â Â Â Â Â Â Â && (MIN (src_align, dest_align) / BITS_PER_UNIT >=
> + Â Â Â Â Â Â Â Â Â Â tree_low_cst (len, 1))))
>= on next line.
> + Â Â Â Â /* If *src and *dest can't overlap, optimize into memcpy as well. Â*/
> + Â Â Â Â srcvar = build_fold_indirect_ref (src);
> + Â Â Â Â destvar = build_fold_indirect_ref (dest);
> + Â Â Â Â if (srcvar && !TREE_THIS_VOLATILE (srcvar)
> + Â Â Â Â Â Â && destvar && !TREE_THIS_VOLATILE (destvar))
Line up && vertically.
Diego.