public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Behaviour differences on x86 and RISC-V on cos/sin functions
@ 2022-12-08 18:23 Ludovic Henry
  2022-12-08 18:49 ` Joseph Myers
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Henry @ 2022-12-08 18:23 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]

Hello,

As part of some OpenJDK work on RISC-V, I've stumbled upon a behavior
difference in cos/sin functions between x86 and RISC-V. It's not clear to
me whether the difference in behavior is acceptable, and whether it should
be handled in the OpenJDK (or other relevant libraries).

The simple test case I have which runs successfully on x86 but not RISC-V
is the following:

```
#include <stdint.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

void main(int argc, char* argv[]) {
    int64_t bitsNaN = 0x7fff800000000000L;
    double valNaN = *((double*)&bitsNaN);

    double resD = acos(valNaN);
    int64_t res = *((int64_t*)&resD);
    if (!(res == bitsNaN)) {
        printf("expected 0x%lx but got 0x%lx\n", bitsNaN, res);
        exit(1);
    }
}
```

I can see that there are some NaN related tests in glibc already at
glibc/math/libm-test-acos.inc#L25-26 and that some are failing at
https://sourceware.org/glibc/wiki/Release/2.35#RISC-V_.28rv64imafdc.2Flp64d.29
and
https://sourceware.org/glibc/wiki/Release/2.36#RISC-V_.28rv64imafdc.2Flp64d.29.
I'm not sure exactly which test is failing though.

What do you think?

Thank you,
Ludovic

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

end of thread, other threads:[~2022-12-08 20:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 18:23 Behaviour differences on x86 and RISC-V on cos/sin functions Ludovic Henry
2022-12-08 18:49 ` Joseph Myers
2022-12-08 19:24   ` Ludovic Henry
2022-12-08 19:58     ` Palmer Dabbelt
2022-12-08 20:06       ` Joseph Myers
2022-12-08 20:07         ` Palmer Dabbelt
2022-12-08 19:59     ` Joseph Myers

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