public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/114284] [14 Regression] arm: Load of volatile short gets miscompiled (loaded twice) since r14-8319
Date: Sat, 09 Mar 2024 12:05:12 +0000	[thread overview]
Message-ID: <bug-114284-4-5F2AA04R0G@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114284-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:3e3e4156a5f93e6d62101594ca6660ee9ce9c10e

commit r14-9412-g3e3e4156a5f93e6d62101594ca6660ee9ce9c10e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 9 13:04:26 2024 +0100

    fwprop: Restore previous behavior for forward propagation of RTL with MEMs
[PR114284]

    Before the recent PR111267 r14-8319 fwprop changes, fwprop would never try
    to propagate what was not considered PROFITABLE, where the profitable part
    actually was partly about profitability, partly about very good reasons
    not to actually propagate and partly for cases where propagation is
    completely incorrect.
    In particular, classify_result has:
      /* Allow (subreg (mem)) -> (mem) simplifications with the following
         exceptions:
         1) Propagating (mem)s into multiple uses is not profitable.
         2) Propagating (mem)s across EBBs may not be profitable if the source
EBB
            runs less frequently.
         3) Propagating (mem)s into paradoxical (subreg)s is not profitable.
         4) Creating new (mem/v)s is not correct, since DCE will not remove the
old
            ones.  */
      if (single_use_p
          && single_ebb_p
          && SUBREG_P (old_rtx)
          && !paradoxical_subreg_p (old_rtx)
          && MEM_P (new_rtx)
          && !MEM_VOLATILE_P (new_rtx))
        return PROFITABLE;
    and didn't mark any other MEM_P (new_rtx) or rtxes which contain
    a MEM in its subrtxes as PROFITABLE.  Now, since r14-8319 profitable_p
    method has been renamed to likely_profitable_p and has just a minor role.
    Now, rule 4) above is something that isn't about profitability, but about
    correct behavior, if you propagate mem/v, the code is miscompiled.
    This particular case has been fixed elsewhere by Haochen in r14-9379.
    But I think even the 1) and 2) and maybe 3) are a strong don't do it,
    don't rely solely on rtx costs, increasing the number of loads of the same
    memory, even when cached, is undesirable, canceling load hoisting can
    be undesirable as well.

    So, the following patch restores previous behavior of src contains any
MEMs,
    in that case likely_profitable_p () is taken as the old profitable_p ()
    as a requirement rather than just a hint.  For propagation of something
    which doesn't load from memory this keeps the r14-8319 behavior.

    2024-03-09  Jakub Jelinek  <jakub@redhat.com>

            PR target/114284
            * fwprop.cc (try_fwprop_subst_pattern): Don't propagate
            src containing MEMs unless prop.likely_profitable_p ().

  parent reply	other threads:[~2024-03-09 12:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08 13:12 [Bug target/114284] New: [14 Regression] arm: Load of volatile short gets miscompiled (loaded twice) acoplan at gcc dot gnu.org
2024-03-08 13:25 ` [Bug target/114284] " rguenth at gcc dot gnu.org
2024-03-08 14:31 ` [Bug target/114284] [14 Regression] arm: Load of volatile short gets miscompiled (loaded twice) since r14-8319 jakub at gcc dot gnu.org
2024-03-08 15:02 ` acoplan at gcc dot gnu.org
2024-03-08 15:03 ` jakub at gcc dot gnu.org
2024-03-08 15:05 ` jakub at gcc dot gnu.org
2024-03-08 15:30 ` jakub at gcc dot gnu.org
2024-03-09 12:05 ` cvs-commit at gcc dot gnu.org [this message]
2024-03-09 15:03 ` law at gcc dot gnu.org
2024-03-09 15:03 ` law at gcc dot gnu.org
2024-03-10  1:12 ` roger at nextmovesoftware dot com

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-114284-4-5F2AA04R0G@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).