https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121590
--- Comment #1 from Kang-Che Sung <Explorer09 at gmail dot com> ---
I update the report with a slightly better example.
```c
#include <limits.h>
#include <math.h>
#include <stdlib.h>
int float_compare_2(double a, double b) {
if (isunordered(a, b))
return INT_MIN;
if (islessgreater(a, b))
return a > b ? 1 : -1;
if (isgreaterequal(a, b))
return 0;
abort();
}
```
x86-64 gcc 15.2 with `-Os` option produces:
```assembly
float_compare_2:
ucomisd %xmm1, %xmm0
jp .L6
je .L3
comisd %xmm1, %xmm0
movl $-1, %edx
movl $1, %eax
cmovbe %edx, %eax
ret
.L3:
jnb .L11
pushq %rax
call abort
.L6:
movl $-2147483648, %eax
ret
.L11:
xorl %eax, %eax
ret
```
Note that isunordered(), islessgreater() and isgreaterequal() all use the same
compare result of the UCOMISD instruction. Yet gcc doesn't recognize that the
four relations would be exhausted after the three function/macro calls.
(The COMISD instruction not merged with UCOMISD is a separate bug, which I've
reported in bug 121887.)