public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug translation/109132] New: Apple M1 floating point bug when optimizing @ 2023-03-14 20:07 muecker at gwdg dot de 2023-03-14 20:10 ` [Bug target/109132] " pinskia at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: muecker at gwdg dot de @ 2023-03-14 20:07 UTC (permalink / raw) To: gcc-bugs 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109132] Apple M1 floating point bug when optimizing 2023-03-14 20:07 [Bug translation/109132] New: Apple M1 floating point bug when optimizing muecker at gwdg dot de @ 2023-03-14 20:10 ` pinskia at gcc dot gnu.org 2023-03-14 20:11 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-14 20:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109132 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- ubuntu@ubuntu:~\# ~/upstream-gcc/bin/gcc t.c -O2 -ffp-contract=off ubuntu@ubuntu:~\# ./a.out 0x1.2eab1ep-2 0x0p+0 ubuntu@ubuntu:~\# ~/upstream-gcc/bin/gcc t.c -O2 ubuntu@ubuntu:~\# ./a.out 0x1.2eab1ep-2 0x1.1b990cp-29 NOT a bug. the use of FMA increases precission here ... ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109132] Apple M1 floating point bug when optimizing 2023-03-14 20:07 [Bug translation/109132] New: Apple M1 floating point bug when optimizing muecker at gwdg dot de 2023-03-14 20:10 ` [Bug target/109132] " pinskia at gcc dot gnu.org @ 2023-03-14 20:11 ` pinskia at gcc dot gnu.org 2023-03-14 20:14 ` pinskia at gcc dot gnu.org 2023-03-14 20:29 ` muecker at gwdg dot de 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-14 20:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109132 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > ubuntu@ubuntu:~\# ~/upstream-gcc/bin/gcc t.c -O2 -ffp-contract=off > ubuntu@ubuntu:~\# ./a.out > 0x1.2eab1ep-2 0x0p+0 > ubuntu@ubuntu:~\# ~/upstream-gcc/bin/gcc t.c -O2 > ubuntu@ubuntu:~\# ./a.out > 0x1.2eab1ep-2 0x1.1b990cp-29 > > > > NOT a bug. the use of FMA increases precission here ... Note this was done on aarch64-linux-gnu with a GCC built from 20230310. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109132] Apple M1 floating point bug when optimizing 2023-03-14 20:07 [Bug translation/109132] New: Apple M1 floating point bug when optimizing muecker at gwdg dot de 2023-03-14 20:10 ` [Bug target/109132] " pinskia at gcc dot gnu.org 2023-03-14 20:11 ` pinskia at gcc dot gnu.org @ 2023-03-14 20:14 ` pinskia at gcc dot gnu.org 2023-03-14 20:29 ` muecker at gwdg dot de 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-14 20:14 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109132 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note you get the same results on x86_64 with -mfma too. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109132] Apple M1 floating point bug when optimizing 2023-03-14 20:07 [Bug translation/109132] New: Apple M1 floating point bug when optimizing muecker at gwdg dot de ` (2 preceding siblings ...) 2023-03-14 20:14 ` pinskia at gcc dot gnu.org @ 2023-03-14 20:29 ` muecker at gwdg dot de 3 siblings, 0 replies; 5+ messages in thread From: muecker at gwdg dot de @ 2023-03-14 20:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109132 --- Comment #4 from Martin Uecker <muecker at gwdg dot de> --- Seems you are right. Thanks! I get it for gcc-10 but not gcc-12 with -mfma on x86. Apparently, WG14 made a change at some point to allow this. But GCC does not implement the pragma to turn it off... ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-14 20:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-14 20:07 [Bug translation/109132] New: Apple M1 floating point bug when optimizing muecker at gwdg dot de 2023-03-14 20:10 ` [Bug target/109132] " pinskia at gcc dot gnu.org 2023-03-14 20:11 ` pinskia at gcc dot gnu.org 2023-03-14 20:14 ` pinskia at gcc dot gnu.org 2023-03-14 20:29 ` muecker at gwdg dot de
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).