Skip to content

[GlobalOpt] Reduction of global aggregate with alignment constraint unnecessarily propagates alignment to some elements #115282

@brunodf-snps

Description

@brunodf-snps

When GlobalOpt performs SRA on a global aggregate with an alignment constraint, it seems to propagate the alignment to some of the elements haphazardly. For example:

alignas(32) static int params[8];

On a plain 32 bit architecture, the array elements respectively have alignment: 32, 4, 8, 4, 16, 4, 8, 4
GlobalOpt SRA creates individual global variables for the elements with respective alignments: 32, 32, 8, 32, 16, 32, 8, 32

I don't see any benefit to increase the alignments elements 1, 3, 5, 7 from 4 to 32. This is wasteful because the new elements cannot be mapped consecutively in memory anymore.

Godbolt demo: https://godbolt.org/z/WjbPjY9Kh

Metadata

Metadata

Assignees

No one assigned

    Labels

    ipoInterprocedural optimizations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions