https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109132
Bug ID: 109132 Summary: Apple M1 floating point bug when optimizing Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: translation Assignee: unassigned at gcc dot gnu.org Reporter: muecker at gwdg dot de Target Milestone: --- There seems to be a floating point error when optimizing on Apple M1. When taking the conjugate of a complex number and multiplying with itself, then the imaginary part should be zero. % cat bug.c #include <stdio.h> #include <complex.h> __attribute__((noinline)) complex float f(complex float a, complex float b) { return a * conjf(b); } int main() { complex float x = -0x1.f5cf72p-3 + 0x1.f0f84ap-2i; complex float y = f(x, x); printf("%a %a\n", crealf(y), cimagf(y)); return (0. != cimagf(y)); } % gcc-12 bug.c % ./a.out && echo ok 0x1.2eab1ep-2 0x0p+0 ok % gcc-12 -O1 bug.c % ./a.out && echo ok 0x1.2eab1ep-2 0x0p+0 ok % gcc-12 -O2 bug.c % ./a.out && echo ok 0x1.2eab1ep-2 0x1.1b990cp-29 % gcc-12 --version gcc-12 (Homebrew GCC 12.2.0) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.