https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92801
Bug ID: 92801 Summary: Drop unused struct fields Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: christoph.muell...@theobroma-systems.com CC: marxin at gcc dot gnu.org Target Milestone: --- Non-escaping structs [1] can have their unused fields removed such that they have a smaller memory footprint and thus allow a more efficient cache utilisation. We are currently working on such a pass and want to use this ticket to further publish details and patches, and to collect feedback from the community. First implementation details: * Iterate with gsi over function bodies to find field accesses (e.g. in assignment, call, cond or switch statements). * Allowed for removal if never accessed * Allowed for removal if write-only (incl. removal of write statements) * Removal based on modification of DECL_CHAIN() of TYPE_FIELDS(t) Early tests showed, that this has the potential to eliminate struct fields nextout and nextin from struct arc of CPU2017's mcf benchmark. As elements of an struct arc array are accessed for the main calculation in the hot loop, this benchmark is a good example, where this pass will help. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92800