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 rtl-optimization/110237] gcc.dg/torture/pr58955-2.c is miscompiled by RTL scheduling after reload
Date: Wed, 21 Jun 2023 07:33:58 +0000	[thread overview]
Message-ID: <bug-110237-4-y4n5NeI4Bu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110237-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Hongtao.liu from comment #7)
> > So it looks like a generic problem and better to be handled in
> > expand_partial_{load, store}_optab_fn?
> 
> There're many other places with assumption MEM_SIZE is equal to MODE_SIZE
> even !MEM_SIZE_KNOWN_P, .i.e. ao_ref_base will rewrite size to MODE_SIZE.

Yes, that's because MEM_EXPR isn't really correct ... I guess we could
work around that in ao_ref_from_mem but expand_partial_store_optab_fn
is wrong in setting that.

There's no "partial memory" MEM, and AFAIK the memory attributes are
only additional info and ignoring them is valid, so indeed a pass
could at least interpret inputs and outputs in mode size even when
UNSPECs are involved.  But it must not(?) interpret them as must uses
or kills?

I also think that MEM_SIZE is really only relevant for BLKmode MEMs,
MEM_OFFSET is only relevant for interpreting MEM_EXPR.

Clearing MEM_EXPR and MEM_SIZE results in an ICE:

#0  fancy_abort (file=0x31ce278
"/space/rguenther/src/gcc11queue/gcc/rtlanal.cc", line=469, 
    function=0x31d0560 <rtx_addr_can_trap_p_1(rtx_def const*, poly_int<1u,
long>, poly_int<1u, long>, machine_mode, bool)::__FUNCTION__>
"rtx_addr_can_trap_p_1") at
/space/rguenther/src/gcc11queue/gcc/diagnostic.cc:2232
#1  0x000000000158b62b in rtx_addr_can_trap_p_1 (x=0x7ffff6d51798, offset=...,
size=..., mode=E_V16SImode, unaligned_mems=false)
    at /space/rguenther/src/gcc11queue/gcc/rtlanal.cc:467
#2  0x0000000001591a2d in may_trap_p_1 (x=0x7ffff6d51780, flags=0) at
/space/rguenther/src/gcc11queue/gcc/rtlanal.cc:3160
#3  0x0000000001591f64 in may_trap_p (x=0x7ffff6d51780) at
/space/rguenther/src/gcc11queue/gcc/rtlanal.cc:3283
#4  0x00000000015f32e6 in simplify_context::simplify_ternary_operation
(this=0x7fffffffcd28, code=VEC_MERGE, mode=E_V16SImode, 
    op0_mode=E_V16SImode, op0=0x7ffff6e21d90, op1=0x7ffff6d51780,
op2=0x7ffff6d51108)
    at /space/rguenther/src/gcc11queue/gcc/simplify-rtx.cc:7040
#5  0x0000000000f590c7 in simplify_ternary_operation (code=VEC_MERGE,
mode=E_V16SImode, op0_mode=E_V16SImode, op0=0x7ffff6e21d90, 
    op1=0x7ffff6d51780, op2=0x7ffff6d51108) at
/space/rguenther/src/gcc11queue/gcc/rtl.h:3498

(gdb) p debug_rtx (op1)
(mem:V16SI (plus:DI (reg/f:DI 113)
        (reg:DI 90 [ _22 ])) [1  A32])

where I have only preserved MEM_ALIAS_SET and MEM_ALIGN.  It insists
on knowing the MEMs size if it's not BLKmode or VOIDmode.  Indeed
from the mode we can derived its size.

So we can simply clear only MEM_EXPR (and MEM_OFFSET), that cuts off the
problematic part of alias analysis.  Together with UNSPEC this might be
enough to fix things.

I'm going to test such a patch and seek for feedback on the mailing list.

  parent reply	other threads:[~2023-06-21  7:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13 13:50 [Bug rtl-optimization/110237] New: " rguenth at gcc dot gnu.org
2023-06-14 11:02 ` [Bug rtl-optimization/110237] " amonakov at gcc dot gnu.org
2023-06-14 12:09 ` rguenth at gcc dot gnu.org
2023-06-20  9:52 ` rguenth at gcc dot gnu.org
2023-06-20 11:35 ` crazylht at gmail dot com
2023-06-20 12:20 ` rguenther at suse dot de
2023-06-20 16:05 ` crazylht at gmail dot com
2023-06-21  5:48 ` crazylht at gmail dot com
2023-06-21  7:33 ` rguenth at gcc dot gnu.org [this message]
2023-06-25  4:06 ` crazylht at gmail dot com
2023-06-26  7:41 ` rguenther at suse dot de
2023-06-26  7:58 ` amonakov at gcc dot gnu.org
2023-06-26  8:07 ` rguenther at suse dot de
2023-06-26  8:22 ` amonakov at gcc dot gnu.org
2023-06-26  8:35 ` rguenther at suse dot de
2023-06-26  8:44 ` crazylht at gmail dot com
2023-06-26  8:54 ` amonakov at gcc dot gnu.org
2023-06-26 11:14 ` rguenther at suse dot de
2023-06-26 18:19 ` amonakov at gcc dot gnu.org
2023-06-27  6:53 ` rguenther at suse dot de
2023-06-27  7:30 ` cvs-commit at gcc dot gnu.org
2023-06-27  9:50 ` amonakov at gcc dot gnu.org
2023-06-27 10:03 ` rguenther at suse dot de
2023-06-29  1:27 ` cvs-commit at gcc dot gnu.org
2023-06-29  1:28 ` cvs-commit at gcc dot gnu.org
2023-06-29  1:29 ` cvs-commit at gcc dot gnu.org
2023-11-27 12:39 ` rdapp at gcc dot gnu.org
2023-11-29 12:26 ` cvs-commit at gcc dot gnu.org
2023-11-29 12:27 ` rguenth 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-110237-4-y4n5NeI4Bu@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).