From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 19AFF3858D3C; Wed, 19 Oct 2022 06:52:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19AFF3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666162354; bh=CsqtCUqlAiIB3eDMkyjBEBpD7J74pi6LpsIfqXl5Gq4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lJVt6dfwRYXKJXfopkTyxhTfHaKsMae938q4O9MMRCCR8ltrEG85Vh2t3Mycu7nIi UeIzm9IIYFIyQg6f9dqnu0Di01PaYT2jv22C4AHioddEdAxMJ144QhlpxDOnhPjDtR 0JLjNUFrHMCqG5eEpPjJz+p8rWHdTx7S/jTEfwfQ= From: "rguenth at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: missed-optimization, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: priority blocked cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106786 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P2 Blocks| |100453 CC| |jamborm at gcc dot gnu.org --- Comment #3 from Richard Biener --- 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):=20 +Will attempt to totally scalarize D.2452 (UID: 2452):=20 Changing the type of a replacement for a offset: 64, size: 8 to an intege= r. -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=3D100453 [Bug 100453] [12 Regression] wrong code at -O1 and above since r12-434=