public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96804] New: Arguments are swapped in floating-point addition
@ 2020-08-26 17:38 chfast at gmail dot com
  2020-08-26 17:38 ` [Bug c/96804] " chfast at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: chfast at gmail dot com @ 2020-08-26 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96804
           Summary: Arguments are swapped in floating-point addition
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chfast at gmail dot com
  Target Milestone: ---

Created attachment 49132
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49132&action=edit
C source code

In the following function, when compiling without optimizations -O0 with GCC
10.2.0 (x86_64-linux-gnu) the arguments to the add instructions are swapped.

float fadd(const float* a, const float* b)
{
    return *a + *b;
}

Assembly snippet:

        movq    %rdi, -8(%rbp)   # a
        movq    %rsi, -16(%rbp)  # b
        movq    -8(%rbp), %rax   # a
        movss   (%rax), %xmm1    # *a
        movq    -16(%rbp), %rax  # b
        movss   (%rax), %xmm0    # *b
        addss   %xmm1, %xmm0     # = *b + *a

This is a problem because when both arguments are NaNs, the result may be
different than the one predicted by IEEE 754.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-27  6:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 17:38 [Bug c/96804] New: Arguments are swapped in floating-point addition chfast at gmail dot com
2020-08-26 17:38 ` [Bug c/96804] " chfast at gmail dot com
2020-08-26 17:47 ` glisse at gcc dot gnu.org
2020-08-26 17:59 ` chfast at gmail dot com
2020-08-26 22:51 ` [Bug target/96804] " joseph at codesourcery dot com
2020-08-27  6:13 ` rguenth at gcc dot gnu.org

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).