https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128670

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 66159
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66159&action=edit
Patch in testing

The x86-64 psABI classifies an aggregate by classifying each of its
fields, and thus each array element, recursively and merging the classes
of the fields sharing an eightbyte.  Zero-width bit-fields are NO_CLASS.

classify_argument classified only the first element of an array and
replicated its classes over the eightbytes of the array.  This is exact
only when the element size is a multiple of a word.  For an element like
struct { char x; int:0; } at an odd offset, the classes of the first
element are { INTEGER, NO_CLASS }, so the eightbyte that holds the
second element is classified as NO_CLASS and its data is not returned in
a register.  Replicating also gives a wrong partial class when the first
element does not use a whole eightbyte that other elements use, e.g. an
SSEHF class for an eightbyte that holds 8 bytes of _Float16 data.

Classify each element of an array at its actual offset and merge the
classes of the elements sharing an eightbyte.  The promotion of partial
classes is applied to the first class of each element, so that the
classification of arrays that were classified correctly is unchanged.
Arrays larger than two eightbytes with more than one element are always
passed in memory, so return early for them.

Assisted-by: Claude Sonnet 5.5

Reply via email to