https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98169
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:66dea8899df6475d5cb289491dbbff307c16c1a7 commit r11-5898-g66dea8899df6475d5cb289491dbbff307c16c1a7 Author: Jakub Jelinek <ja...@redhat.com> Date: Thu Dec 10 11:46:08 2020 +0100 dojump: Optimize a == a or a != a [PR98169] If the backend doesn't have floating point EQ or NE comparison, dojump.c splits it into ORDERED && UNEQ or UNORDERED || LTGT. If both comparison operands are the same, we know the result of the second comparison though, a == b is equivalent to a ord b and a != b is equivalent to a unord b, and thus can just use ORDERED or UNORDERED. On the testcase, this changes f1: - ucomiss %xmm0, %xmm0 - movl $1, %eax - jp .L3 - jne .L3 - ret - .p2align 4,,10 - .p2align 3 -.L3: xorl %eax, %eax + ucomiss %xmm0, %xmm0 + setnp %al and f3: - ucomisd %xmm0, %xmm0 - movl $1, %eax - jp .L8 - jne .L8 - ret - .p2align 4,,10 - .p2align 3 -.L8: xorl %eax, %eax + ucomisd %xmm0, %xmm0 + setnp %al while keeping the same code for f2 and f4. 2020-12-10 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/98169 * dojump.c (do_compare_rtx_and_jump): Don't split self-EQ/NE comparisons, just use ORDERED or UNORDERED. * gcc.target/i386/pr98169.c: New test.