public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "avieira at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/104498] New: Alias attribute being ignored by scheduler
Date: Fri, 11 Feb 2022 09:25:42 +0000	[thread overview]
Message-ID: <bug-104498-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104498

            Bug ID: 104498
           Summary: Alias attribute being ignored by scheduler
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avieira at gcc dot gnu.org
  Target Milestone: ---

Whilst working on a tuning structure I saw a correctness regression that I
believe is a result of the alias attribute not working properly.

You can reproduce it using an existing tuning for AArch64 using:
gcc -O2 src/gcc/gcc/testsuite/gcc.c-torture/execute/alias-2.c -S
-mtune=cortex-a34

This will lead to the 'a[off] = 2' store being moved after the b load in
'b[off] != 2'.

In RTL:

(insn 23 18 19 2 (set (reg:SI 110 [ b[off.0_1] ])
        (mem:SI (plus:DI (mult:DI (reg:DI 99 [ off.0_1 ])
                    (const_int 4 [0x4]))
                (reg/f:DI 97)) [1 b[off.0_1]+0 S4 A32]))
"gcc/gcc/testsuite/gcc.c-torture/execute/alias-2.c":10:6 52 {*movsi_aarch64}
     (expr_list:REG_DEAD (reg:DI 99 [ off.0_1 ])
        (expr_list:REG_DEAD (reg/f:DI 97)
            (nil))))
(insn 19 23 24 2 (set (mem:SI (plus:DI (mult:DI (reg:DI 99 [ off.0_1 ])
                    (const_int 4 [0x4]))
                (reg/f:DI 104)) [1 a[off.0_1]+0 S4 A32])
        (reg:SI 106)) "gcc/gcc/testsuite/gcc.c-torture/execute/alias-2.c":9:9
52 {*movsi_aarch64}
     (expr_list:REG_DEAD (reg:SI 106)
        (expr_list:REG_DEAD (reg/f:DI 104)
            (nil))))

After some debugging I found that true_dependence returns false for these two
memory accesses because base_alias_check sees they have different base objects
('a' and 'b') and deduces they can't alias based on that, without realising 'b'
isn't an actual base object but an alias to 'a'. I think we should make it so
that at expand pointers to 'b' get 'a' as a base object.

             reply	other threads:[~2022-02-11  9:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  9:25 avieira at gcc dot gnu.org [this message]
2022-02-11  9:26 ` [Bug rtl-optimization/104498] " avieira at gcc dot gnu.org
2022-02-11 10:27 ` rguenth at gcc dot gnu.org
2022-02-11 11:52 ` avieira at gcc dot gnu.org
2022-02-11 12:10 ` rguenth at gcc dot gnu.org
2022-02-11 12:50 ` avieira at gcc dot gnu.org
2022-02-11 13:21 ` rsandifo at gcc dot gnu.org
2022-02-11 13:56 ` avieira at gcc dot gnu.org
2022-02-11 14:31 ` rsandifo at gcc dot gnu.org
2022-02-21  9:45 ` cvs-commit at gcc dot gnu.org
2022-02-21 11:39 ` avieira at gcc dot gnu.org

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=bug-104498-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).