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