Issue 181121
Summary [libc][math] FP addition sometimes gives the wrong output sign
Labels libc
Assignees
Reporter statham-arm
    Tiny test program `test.c`:
```c
#include <stdio.h>

extern _Float16 f16add(double x, double y);

int main(void)
{
    double a = 1.0, b = -5.0;
    _Float16 f = f16add(a, b);
    printf("%g + %g = %g\n", a, b, (double)f);
}
```

Build LLVM libc and compile and link this program against it. (I tested on ordinary x86 Ubuntu 24.04, as of a recent llvm-project commit 6420099bcc62a09e002e500870216b2dd9d256a9.)
```
cmake -B build -S ${llvm_project?}/runtimes -DLLVM_ENABLE_RUNTIMES=libc
cmake --build build
clang -o test test.c build/libc/lib/libllvmlibc.a
./test
```

Output:
```
1 + -5 = 4
```

But 1 + −5 = −4, not +4.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to