public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "muecker at gwdg dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug translation/109132] New: Apple M1 floating point bug when optimizing
Date: Tue, 14 Mar 2023 20:07:00 +0000	[thread overview]
Message-ID: <bug-109132-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2023-03-14 20:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 20:07 muecker at gwdg dot de [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109132-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).