| Issue |
244636
|
| Summary |
[SPARC] strict fp128 compares call _Qp_cmpe/_Qp_cmp instead of _Qp_flt, _Qp_feq etc.
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
shalseth
|
With `-frounding-math`, every `fp128` compare on sparc64 becomes a call to `_Qp_cmpe` or `_Qp_cmp` plus a decode of the result. That happens even for predicates that have a dedicated helper with the right exception behaviour. Without `-frounding-math` clang uses `_Qp_flt`, `_Qp_fle`, `_Qp_fgt`, `_Qp_fge`, `_Qp_feq` and `_Qp_fne`. GCC uses them with or without it.
```c
int lt (long double a, long double b) { return a < b; }
int le (long double a, long double b) { return a <= b; }
int gt (long double a, long double b) { return a > b; }
int ge (long double a, long double b) { return a >= b; }
int eq (long double a, long double b) { return a == b; }
int ne (long double a, long double b) { return a != b; }
```
```
$ clang -O2 -S t.c -o - | grep call
call _Qp_flt
call _Qp_fle
call _Qp_fgt
call _Qp_fge
call _Qp_feq
call _Qp_fne
$ clang -O2 -frounding-math -S t.c -o - | grep call
call _Qp_cmpe
call _Qp_cmpe
call _Qp_cmpe
call _Qp_cmpe
call _Qp_cmp
call _Qp_cmp
```
The results and the exceptions are correct either way. `_Qp_flt`, `_Qp_fle`, `_Qp_fgt` and `_Qp_fge` raise invalid for any NaN, like `fcmpeq`. `_Qp_feq` and `_Qp_fne` raise it only for a signaling NaN, like `fcmpq`. I compared a quiet NaN with 1.0 in both builds. FE_INVALID was set for `<`, `<=`, `>` and `>=`, and clear for `==` and `!=`. So the dedicated helpers match `fcmps` OLT/OLE/OGT/OGE and `fcmp` OEQ/UNE. `LowerF128StrictCompare` only needs `_Qp_cmp` and `_Qp_cmpe` for the other predicates. The same applies to `_Q_*` on 32-bit SPARC.
This also shows up in glibc, which builds libc with `-frounding-math`. A clang-built sparc64 libc.so calls `_Qp_cmpe` from `strfmon_l`, `printf_size`, `qecvt_r` and `qfcvt_r`. The GCC build calls `_Qp_flt` and friends there. `_Qp_cmpe` isn't among the helpers glibc's elf/check-localplt test allows for sparc64, so the test fails (https://github.com/sparclinux/issues/issues/96).
LLVM main 1ed0efd70af1, SPARC M7, Linux sparc64.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs