https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116896
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 59267 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59267&action=edit gcc15-pr116896-wip.patch Untested WIP patch. Compared to unpatched compiler, float <=> without -ffast-math changes from: comiss %xmm1, %xmm0 jp .L4 seta %al movl $0, %edx leal -1(%rax,%rax), %eax cmove %edx, %eax ret .L4: movl $2, %eax ret to comiss %xmm1, %xmm0 jp .L2 seta %al movzbl %al, %eax sbbl $0, %eax ret .L2: movl $2, %eax ret , float -ffast-math <=> from comiss %xmm1, %xmm0 movl $0, %edx seta %al leal -1(%rax,%rax), %eax cmove %edx, %eax ret to xorl %eax, %eax comiss %xmm1, %xmm0 seta %al sbbb $0, %al ret int <=> from cmpl %esi, %edi movl $0, %edx setge %al leal -1(%rax,%rax), %eax cmove %edx, %eax ret to xorl %edx, %edx cmpl %esi, %edi setg %al setl %dl movzbl %al, %eax subl %edx, %eax ret and unsigned <=> from xorl %eax, %eax cmpl %esi, %edi je .L7 sbbl %eax, %eax orl $1, %eax .L7: ret to xorl %eax, %eax cmpl %edi, %esi setg %al sbbb $0, %al ret Wonder if it is better to zero extend the setcc results to wider mode before the subtraction or do the sub/sbb in QImode and sign extend afterwards. My testcases were just doing auto foo (float x, float y) { return x <=> y; } auto bar (int x, int y) { return x <=> y; } auto baz (unsigned x, unsigned y) { return x <=> y; } and so actually need just 8-bit result and combine is able to tweak it in all but one case (signed int).