public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/104498] New: Alias attribute being ignored by scheduler
@ 2022-02-11  9:25 avieira at gcc dot gnu.org
  2022-02-11  9:26 ` [Bug rtl-optimization/104498] " avieira at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: avieira at gcc dot gnu.org @ 2022-02-11  9:25 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-21 11:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11  9:25 [Bug rtl-optimization/104498] New: Alias attribute being ignored by scheduler avieira at gcc dot gnu.org
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

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).