This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: movmem pattern and missed alignment


On 10/08/2018 07:38 PM, Paul Koning wrote:
> 
> 
>> On Oct 8, 2018, at 1:29 PM, Andrew Haley <aph@redhat.com> wrote:
>>
>> On 10/08/2018 06:20 PM, Michael Matz wrote:
>>> Only if you somewhere visibly add accesses to *i and *j.  Without them you 
>>> only have the "accesses" via memcpy, and as Richi says, those don't imply 
>>> any alignment requirements.  The i and j pointers might validly be char* 
>>> pointers in disguise and hence be in fact only 1-aligned.  I.e. there's 
>>> nothing in your small example program from which GCC can infer that those 
>>> two global pointers are in fact 2-aligned.
>>
>> So all you'd actually have to say is
>>
>> void f1(void)
>> {
>>    *i; *j;
>>    __builtin_memcpy (i, j, 32);
>> }
> 
> No, that doesn't help. 

It could do.

> Not even if I make it:
> 
> void f1(void)
> {
>     k = *i + *j;
>     __builtin_memcpy (i, j, 4);
> }
> 
> The first line does word aligned references to *i and *j, but the memcpy stubbornly remains a byte move.

Right, so that is a missed optimization.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]