public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/113255] [11/12/13/14 Regression] wrong code with -O2 -mtune=k8
Date: Tue, 09 Jan 2024 07:52:50 +0000	[thread overview]
Message-ID: <bug-113255-4-FoUNMce1b9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113255-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
DSE thinks the store is dead because it falls off the function.

(insn 41 40 46 4 (set (mem/c:SI (plus:DI (reg/f:DI 19 frame)
                (const_int -36 [0xffffffffffffffdc])) [2 e[1].y+0 S4 A32])
        (reg:SI 98 [ e$1$y ])) "t.c":21:9 85 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 98 [ e$1$y ])
        (nil)))

...

(insn 64 63 68 4 (parallel [
            (set (reg:DI 131)
                (const_int 0 [0]))
            (set (reg/f:DI 129)
                (plus:DI (ashift:DI (reg:DI 131)
                        (const_int 3 [0x3]))
                    (reg/f:DI 129)))
            (set (reg/f:DI 119)
                (plus:DI (ashift:DI (reg:DI 131)
                        (const_int 3 [0x3]))
                    (reg/f:DI 119)))
            (set (mem/c:BLK (reg/f:DI 129) [1  A64])
                (mem/c:BLK (reg/f:DI 119) [1  A8]))
            (use (reg:DI 131))
        ]) "t.c":21:9 1416 {*rep_movdi_rex64}
     (expr_list:REG_UNUSED (reg:DI 131)
        (expr_list:REG_UNUSED (reg/f:DI 129)
            (expr_list:REG_UNUSED (reg/f:DI 119)
                (nil)))))

it appears to be a bit convoluted how we compute the source of the block
copy (reg/f:DI 119) and this is probably confusing "frame related" vs.
non-frame-related MEM disambiguation.

I'm unsure the above parallel is valid, isn't parallel executing stmts
in "parallel" (unspecified order)?

**scanning insn=64
  mem: (reg/f:DI 119)

   after canon_rtx address: (reg/f:DI 119)

   after cselib_expand address: (minus:DI (plus:DI (reg/f:DI 129)
        (reg/f:DI 133))
    (reg/f:DI 134))

   after canon_rtx address: (minus:DI (plus:DI (reg/f:DI 129)
        (reg/f:DI 133))
    (reg/f:DI 134))
  varying cselib base=17:1741806 offset = 0
 processing cselib load mem:(mem/c:BLK (reg/f:DI 119) [1  A8])
 processing cselib load against insn 55
removing from active insn=55 has store
 processing cselib load against insn 47
removing from active insn=47 has store
 processing cselib load against insn 41
mems_found = 0, cannot_delete = true

we're calling canon_true_dependence with

(gdb) p debug_rtx (store_info->mem)
(mem/c:SI (plus:DI (reg/f:DI 19 frame)
        (const_int -36 [0xffffffffffffffdc])) [2 e[1].y+0 S4 A32])
(gdb) p debug_rtx (mem)
(mem/c:BLK (reg/f:DI 119) [1  A8])
(gdb) p debug_rtx (mem_addr)
(minus:DI (plus:DI (value:DI 8:1741643 @0x49c8ba8/0x49b8e80)
        (value:DI 11:11 @0x49c8bf0/0x49b8f10))
    (value:DI 9:9 @0x49c8bc0/0x49b8eb0))

and find_base_term of the mem_addr is returning

(symbol_ref:DI ("g_e") [flags 0x2] <var_decl 0x7ffff7019c60 g_e>)

which is because of the weird way we compute the source address (involving
the address of the destination).  There's a very old bug about find_base_term
which tends to pick up a wrong base if multiple candidates are involved.

I can't decipher this from what expand generates but the problem lies
there (the rep_8bytes expansion).

  parent reply	other threads:[~2024-01-09  7:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 23:24 [Bug c/113255] New: " mednafen at sent dot com
2024-01-06 23:53 ` [Bug target/113255] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-01-07 12:13 ` jakub at gcc dot gnu.org
2024-01-07 19:48 ` ubizjak at gmail dot com
2024-01-09  7:52 ` rguenth at gcc dot gnu.org [this message]
2024-01-09  7:58 ` jakub at gcc dot gnu.org
2024-01-09  8:00 ` ubizjak at gmail dot com
2024-01-09  9:27 ` jakub at gcc dot gnu.org
2024-01-09 10:20 ` rguenth at gcc dot gnu.org
2024-01-09 12:09 ` rguenth at gcc dot gnu.org
2024-01-10  8:57 ` rguenth at gcc dot gnu.org
2024-01-12  8:48 ` rguenth at gcc dot gnu.org
2024-01-23  7:08 ` cvs-commit at gcc dot gnu.org
2024-01-23  7:10 ` [Bug target/113255] [11/12/13 " rguenth at gcc dot gnu.org
2024-01-23 14:38 ` cvs-commit at gcc dot gnu.org
2024-02-01 12:53 ` rguenth at gcc dot gnu.org
2024-02-01 13:08 ` rguenth at gcc dot gnu.org
2024-02-05  7:35 ` cvs-commit 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-113255-4-FoUNMce1b9@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).