https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111798
Bug ID: 111798 Summary: [14 Regression] Recent change causing testsuite regression and poor code on mcore-elf Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- This change: commit 6decda1a35be5764101987c210b5693a0d914e58 Author: Richard Biener <rguent...@suse.de> Date: Thu Oct 12 11:34:57 2023 +0200 tree-optimization/111779 - Handle some BIT_FIELD_REFs in SRA The following handles byte-aligned, power-of-two and byte-multiple sized BIT_FIELD_REF reads in SRA. In particular this should cover BIT_FIELD_REFs created by optimize_bit_field_compare. For gcc.dg/tree-ssa/ssa-dse-26.c we now SRA the BIT_FIELD_REF appearing there leading to more DSE, fully eliding the aggregates. This results in the same false positive -Wuninitialized as the older attempt to remove the folding from optimize_bit_field_compare, fixed by initializing part of the aggregate unconditionally. PR tree-optimization/111779 gcc/ * tree-sra.cc (sra_handled_bf_read_p): New function. (build_access_from_expr_1): Handle some BIT_FIELD_REFs. (sra_modify_expr): Likewise. (make_fancy_name_1): Skip over BIT_FIELD_REF. gcc/fortran/ * trans-expr.cc (gfc_trans_assignment_1): Initialize lhs_caf_attr and rhs_caf_attr codimension flag to avoid false positive -Wuninitialized. gcc/testsuite/ * gcc.dg/tree-ssa/ssa-dse-26.c: Adjust for more DSE. * gcc.dg/vect/vect-pr111779.c: New testcase. Causes execute/20040709-2.c to fail on mcore-elf at -O2. It also results in what appears to be significantly poorer code generation. Note I haven't managed to get mcore-elf-gdb to work, so debugging is, umm, painful. And I wouldn't put a lot of faith in the simulator correctness. I have simplified the test to this: extern void abort (void); extern void exit (int); unsigned int myrnd (void) { static unsigned int s = 1388815473; s *= 1103515245; s += 12345; return (s / 65536) % 2048; } struct __attribute__((packed)) K { unsigned int k:6, l:1, j:10, i:15; }; struct K sK; unsigned int fn1K (unsigned int x) { struct K y = sK; y.k += x; return y.k; } void testK (void) { int i; unsigned int mask, v, a, r; struct K x; char *p = (char *) &sK; for (i = 0; i < sizeof (sK); ++i) *p++ = myrnd (); v = myrnd (); a = myrnd (); sK.k = v; x = sK; r = fn1K (a); if (x.j != sK.j || x.l != sK.l) abort (); } int main (void) { testK (); exit (0); } Which should at least make the poor code gen obvious. I don't expect to have time to debug this further anytime in the near future.