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 tree-optimization/106786] [12/13 Regression] SRA regression causes extra instructions sometimes
Date: Wed, 19 Oct 2022 06:52:33 +0000	[thread overview]
Message-ID: <bug-106786-4-l9L3ejiOXN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106786-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
             Blocks|                            |100453
                 CC|                            |jamborm at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The difference is (before SRA) good vs. bad:

+Rejected (2400): not aggregate: x
+Rejected (2401): not aggregate: y
+Candidate (2452): D.2452
+Rejected (2451): not aggregate: d
+Candidate (2447): D.2447
+Rejected (2446): not aggregate: d
+Rejected (2445): not aggregate: carry
+Candidate (2430): a
+Candidate (2404): z
+! Disqualifying z - Encountered a store to a read-only decl.
+Will attempt to totally scalarize D.2447 (UID: 2447): 
+Will attempt to totally scalarize D.2452 (UID: 2452): 
 Changing the type of a replacement for a offset: 64, size: 8  to an integer.
-Created a replacement for a offset: 64, size: 8: a$8D.2422
+Created a replacement for a offset: 64, size: 8: a$8D.2453

so it looks like SRA is confused by 'z' being declared const?

Thus likely caused by r12-1529-gd7deee423f993b

diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 1a3e12f18cc..1f4e5987292 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -922,12 +922,6 @@ create_access (tree expr, gimple *stmt, bool write)
   if (!DECL_P (base) || !bitmap_bit_p (candidate_bitmap, DECL_UID (base)))
     return NULL;

-  if (write && TREE_READONLY (base))
-    {
-      disqualify_candidate (base, "Encountered a store to a read-only decl.");
-      return NULL;
-    }
-
   HOST_WIDE_INT offset, size, max_size;
   if (!poffset.is_constant (&offset)
       || !psize.is_constant (&size)

fixes the regression (leaving the rest of the checks in place, but not sure
how safe that is).

Martin?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100453
[Bug 100453] [12 Regression] wrong code at -O1 and above since r12-434

  parent reply	other threads:[~2022-10-19  6:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 11:16 [Bug tree-optimization/106786] New: Regression in cmp+sbb chfast at gmail dot com
2022-08-31 15:56 ` [Bug tree-optimization/106786] " pinskia at gcc dot gnu.org
2022-08-31 16:03 ` [Bug tree-optimization/106786] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-10-19  6:52 ` rguenth at gcc dot gnu.org [this message]
2022-11-29 12:38 ` [Bug tree-optimization/106786] [12/13 Regression] SRA regression causes extra instructions sometimes chfast at gmail dot com
2022-12-27 14:32 ` [Bug tree-optimization/106786] [12/13 Regression] SRA regression causes extra instructions sometimes since r12-1529-gd7deee423f993bee marxin at gcc dot gnu.org
2023-05-08 12:25 ` [Bug tree-optimization/106786] [12/13/14 " 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-106786-4-l9L3ejiOXN@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).