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

            Bug ID: 129167
           Summary: [x86-64] Wrong code passing struct containing _Complex
                    _Float16 array by value
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

On x86-64, passing the struct below by value loses the last array
element: c[2] arrives as 0 in the callee.

--cut here--
struct S
{
  short s;
  _Complex _Float16 c[3];
};

extern void abort (void);

__attribute__((noipa)) void
check (struct S x)
{
  if (x.s != 7
      || __real__ x.c[0] != 1.0f16 || __imag__ x.c[0] != 2.0f16
      || __real__ x.c[1] != 3.0f16 || __imag__ x.c[1] != 4.0f16
      || __real__ x.c[2] != 5.0f16 || __imag__ x.c[2] != 6.0f16)
    abort ();
}

__attribute__((noipa)) void
call (void)
{
  struct S x = { 7, { 1.0f16 + 2.0if16, 3.0f16 + 4.0if16,
                      5.0f16 + 6.0if16 } };
  check (x);
}

int
main (void)
{
  call ();
  return 0;
}
--cut here--

$ gcc -O2 test.c && ./a.out
Aborted

Reply via email to