Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Aaron Sawdey
On 5/15/19 1:01 PM, Jakub Jelinek wrote: > On Wed, May 15, 2019 at 12:59:01PM -0500, Aaron Sawdey wrote: >> 1) rename optab movmem and the underlying patterns to cpymem. >> 2) add a new optab movmem that is really memmove() and add support for >> having __builtin_memmove() use it. >> >> Handling of

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Jakub Jelinek
On Wed, May 15, 2019 at 12:59:01PM -0500, Aaron Sawdey wrote: > On 5/15/19 11:31 AM, Jakub Jelinek wrote: > > On Wed, May 15, 2019 at 11:23:54AM -0500, Aaron Sawdey wrote: > >> My goals for this are: > >> * memcpy() call becomes __builtin_memcpy and goes to optab[cpymem] > >> * memmove() call bec

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Aaron Sawdey
On 5/15/19 11:31 AM, Jakub Jelinek wrote: > On Wed, May 15, 2019 at 11:23:54AM -0500, Aaron Sawdey wrote: >> My goals for this are: >> * memcpy() call becomes __builtin_memcpy and goes to optab[cpymem] >> * memmove() call becomes __builtin_memmove (or __builtin_memcpy based >>on the gimple an

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Jakub Jelinek
On Wed, May 15, 2019 at 11:23:54AM -0500, Aaron Sawdey wrote: > We currently have gimple_fold_builtin_memory_op() figuring out where there > is no overlap and converging __builtin_memmove() to __builtin_memcpy(). Would > you forsee looking for converting __builtin_memmove() with overlap into > a ca

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Aaron Sawdey
On 5/15/19 9:02 AM, Michael Matz wrote: > On Wed, 15 May 2019, Aaron Sawdey wrote: >> Next question would be how do we move from the existing movmem pattern >> (which Michael Matz tells us should be renamed cpymem anyway) to this >> new thing. Are you proposing that we still have both movmem and

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Michael Matz
Hi, On Wed, 15 May 2019, Jakub Jelinek wrote: > Just one thing to note, our "memcpy" expectation is that either there is > no overlap, or there is 100% overlap (src == dest), both all the current > movmem == future cpymem expanders and all the supported library > implementations do support tha

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Jakub Jelinek
On Wed, May 15, 2019 at 02:02:32PM +, Michael Matz wrote: > > Yes this would be a nice thing to get to, a single move/copy underlying > > builtin, to which we communicate what the compiler's analysis tells us > > about whether the operands overlap and by how much. > > > > Next question would

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Michael Matz
Hi, On Wed, 15 May 2019, Aaron Sawdey wrote: > Yes this would be a nice thing to get to, a single move/copy underlying > builtin, to which we communicate what the compiler's analysis tells us > about whether the operands overlap and by how much. > > Next question would be how do we move from t

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Aaron Sawdey
On 5/15/19 7:22 AM, Richard Biener wrote: > On Tue, May 14, 2019 at 9:21 PM Aaron Sawdey wrote: >> I'd be interested in any comments about pieces of this machinery that need to >> work a certain way, or other related issues that should be addressed in >> between expand_builtin_memcpy() and emit_bl

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Aaron Sawdey
On 5/15/19 8:10 AM, Michael Matz wrote:> On Tue, 14 May 2019, Aaron Sawdey wrote: > >> memcpy -> expand with movmem pattern >> memmove (no overlap) -> transform to memcpy -> expand with movmem pattern >> memmove (overlap) -> remains memmove -> glibc call > ... >> However in builtins.c expand_buil

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Michael Matz
Hi, On Tue, 14 May 2019, Aaron Sawdey wrote: > memcpy -> expand with movmem pattern > memmove (no overlap) -> transform to memcpy -> expand with movmem pattern > memmove (overlap) -> remains memmove -> glibc call ... > However in builtins.c expand_builtin_memmove() does not actually do the > exp

Re: Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-15 Thread Richard Biener
On Tue, May 14, 2019 at 9:21 PM Aaron Sawdey wrote: > > GCC does not currently do inline expansion of overlapping memmove, nor does it > have an expansion pattern to allow for non-overlapping memcpy, so I plan to > add > patterns and support to implement this in gcc 10 timeframe. > > At present m

Fixing inline expansion of overlapping memmove and non-overlapping memcpy

2019-05-14 Thread Aaron Sawdey
GCC does not currently do inline expansion of overlapping memmove, nor does it have an expansion pattern to allow for non-overlapping memcpy, so I plan to add patterns and support to implement this in gcc 10 timeframe. At present memcpy and memmove are kind of entangled. Here's the current state o