public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix PR80222
Date: Sat, 13 May 2017 09:40:00 -0000	[thread overview]
Message-ID: <E627A6F0-BA82-4B27-9C23-C0F2E4C16E02@suse.de> (raw)
In-Reply-To: <4531407.2ddBfSlUQt@polaris>

On May 13, 2017 10:49:31 AM GMT+02:00, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to
>trunk.
>> 
>> Richard.
>> 
>> 2017-03-28  Richard Biener  <rguenther@suse.de>
>> 
>> 	PR middle-end/80222
>> 	* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
>> 	TYPE_REF_CAN_ALIAS_ALL references.
>> 	* fold-const.c (fold_indirect_ref_1): Likewise.
>
>You just backported it onto the 6 branch and the fold_indirect_ref_1
>hunk 
>alone introduced regressions in the C testsuite on the branch for
>strict-
>alignment architectures, e.g. SPARC.  Reduced testcase:
>
>typedef long long V
>__attribute__ ((vector_size (2 * sizeof (long long)), may_alias));
>
>typedef struct S { V b; } P __attribute__((aligned (1)));
>
>__attribute__((noinline, noclone)) void
>bar (P *p)
>{
>  p->b[1] = 5;
>}
>
>Before the patch at -O0:
>
>bar:
>        save    %sp, -96, %sp
>        st      %i0, [%fp+68]
>        ld      [%fp+68], %g1
>        ldub    [%g1+12], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+12]
>        ldub    [%g1+13], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+13]
>        ldub    [%g1+14], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+14]
>        ldub    [%g1+15], %g2
>        and     %g2, 0, %g2
>        or      %g2, 5, %g2
>        stb     %g2, [%g1+15]
>        ldub    [%g1+8], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+8]
>        ldub    [%g1+9], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+9]
>        ldub    [%g1+10], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+10]
>        ldub    [%g1+11], %g2
>        and     %g2, 0, %g2
>        stb     %g2, [%g1+11]
>        nop
>        return  %i7+8
>         nop
>
>
>After the patch:
>
>bar:
>        save    %sp, -96, %sp
>        st      %i0, [%fp+68]
>        ld      [%fp+68], %g1
>        add     %g1, 8, %g1
>        mov     0, %g2
>        mov     5, %g3
>        std     %g2, [%g1]
>        nop
>        return  %i7+8
>         nop
>
>that is to say, the compiler now generates an unaligned store.

Does this happen on the GCC7 branch as well?  The patch just guards an indirect ref folding (I refrained from trying to make it correct given I think it's premature optimization).

I'll try to investigate on Monday if you don't beat me to it.  Feel free to revert the backport in the meantime.

Note I think you can trigger the same bug with some source changes independent of the patch which means the GENERIC must be somehow invalid.

Thanks,
Richard.

  reply	other threads:[~2017-05-13  9:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 10:58 Richard Biener
2017-05-13  9:15 ` Eric Botcazou
2017-05-13  9:40   ` Richard Biener [this message]
2017-05-13 10:24     ` Eric Botcazou
2017-05-15  8:00       ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E627A6F0-BA82-4B27-9C23-C0F2E4C16E02@suse.de \
    --to=rguenther@suse.de \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).