Issue 157874
Summary x86 optimization: Missed merging comparison of isunordered() and islessgreater()
Labels new issue
Assignees
Reporter Explorer09
    ```c
#include <limits.h>
#include <math.h>
#include <stdlib.h>
int func(double x, double y) {
    if (isunordered(x, y))
        return INT_MIN;
    if (islessgreater(x, y))
 return x > y ? 1 : -1;
    return 0;
}
```

https://godbolt.org/z/fPxT3qfPG

x86-64 clang 21.1.0 with `-Os` option produces:

```assembly
func:
        ucomisd xmm0, xmm1
 jp      .LBB0_1
        ucomisd xmm0, xmm1
        je      .LBB0_3
 seta    al
        movzx   eax, al
        lea     eax, [2*rax - 1]
 ret
.LBB0_3:
        xor     eax, eax
        ret
.LBB0_1:
 mov     eax, -2147483648
        ret
```

Note the duplicate UCOMISD instructions.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to