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

            Bug ID: 128304
           Summary: [16/17 Regression] wrong code for _Complex float d[i]
                    -= x[i] * y[i] at -O3 -ffast-math -march=armv8.3-a
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yuki.tanaka at defaultcase dot de
  Target Milestone: ---

__attribute__((noipa)) void a(_Complex float *__restrict d, _Complex float *x,
_Complex float *y, int n)
{
  for (int i = 0; i < n; i++)
    d[i] -= x[i] * y[i];
}

int main(void)
{
  _Complex float x[1] = { 1 + 2i };
  _Complex float y[1] = { 2 + 3i };
  _Complex float d[1] = { 100 + 50i };

  a(d, x, y, 1);

  if (__real__ d[0] != 104 || __imag__ d[0] != 43)
    __builtin_abort();

  return 0;
}

ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 134
Program terminated with signal SIGABRT (6)

(100 + 50i) - (1 + 2i) * (2 + 3i) is 104 + 43i, so d[0] must be 104 + 43i.
Instead d[0] is something else and main aborts. This happens with -O3
-ffast-math (also -Ofast) and -march=armv8.3-a.

Compiler Explorer:
https://godbolt.org/z/W1EhjWGq3

Reply via email to