https://bugs.llvm.org/show_bug.cgi?id=42496

            Bug ID: 42496
           Summary: NaN compares equal for SPARC V9
           Product: libraries
           Version: trunk
          Hardware: Sun
                OS: Solaris
            Status: NEW
          Keywords: miscompilation
          Severity: enhancement
          Priority: P
         Component: Backend: Sparc
          Assignee: unassignedb...@nondot.org
          Reporter: r...@gcc.gnu.org
                CC: llvm-bugs@lists.llvm.org, venka...@cs.wisc.edu

When investigating the last test failures on SPARC (for
https://reviews.llvm.org/D40900),
I found two failures that boil down to long double NaN comparing equal to
itself
on 64-bit SPARC:

    Builtins-sparcv9-sunos :: compiler_rt_logbl_test.c
    Builtins-sparcv9-sunos :: divtc3_test.c

They seem to boil down to the following testcase:

$ cat nancmp.c
#include <math.h>
#include <stdio.h>

int
main (void)
{
  long double lnan = NAN;
  long double mlnan = -NAN;

  if (lnan != lnan)
    printf ("nan neq\n");
  else
    printf ("nan eq\n");

  if (mlnan != mlnan)
    printf ("-nan neq\n");
  else
    printf ("-nan eq\n");

  return 0;
}
$ gcc -m32 -o nancmp nancmp.c && ./nancmp
nan neq
-nan neq
gcc -m64 -o nancmp nancmp.c && ./nancmp
nan neq
-nan neq
$ clang -m32 -o nancmp nancmp.c && ./nancmp
nan neq
-nan neq
$ clang -m64 -o nancmp nancmp.c && ./nancmp
nan eq
-nan eq

This may be due to the fact that clang calls _Qp_cmp for the comparison, which
returns unordered (3) in this case, while gcc uses _Qp_feq, which just returns
unequal (0) instead.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to