Bug 86497 - [8/9 regression] wasted instructions for x86 float x!=x
Summary: [8/9 regression] wasted instructions for x86 float x!=x
Status: RESOLVED DUPLICATE of bug 84251
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.1.0
: P2 normal
Target Milestone: 8.3
Assignee: Not yet assigned to anyone
Keywords: missed-optimization
Depends on:
Reported: 2018-07-11 21:39 UTC by ead
Modified: 2018-12-06 04:25 UTC (History)
2 users (show)

See Also:
Target: x86_64-*-*
Known to work:
Known to fail:
Last reconfirmed: 2018-07-12 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description ead 2018-07-11 21:39:51 UTC
When compiling

bool is_nan1(double x){
    return x!=x;

with g++-8.1  -O3 the resulting assembler (https://godbolt.org/g/BBFM3Q) is 

  ucomisd %xmm0, %xmm0
  movl $1, %edx
  setne %al
  cmovp %edx, %eax

However, for version 7.3 the result was (https://godbolt.org/g/tR69jf) better:

  ucomisd %xmm0, %xmm0
  setp %al

Also for 8.1 -Os is the assembler somewhat strange:

  ucomisd %xmm0, %xmm0
  movb $1, %al
  jp .L2
  setne %al
Comment 1 Richard Biener 2018-07-12 08:50:08 UTC
Confirmed.  I _think_ I've seen a duplicate...
Comment 2 Jakub Jelinek 2018-07-12 10:58:41 UTC
Started with r254167, so maybe related to PR84251.
Comment 3 Uroš Bizjak 2018-07-12 11:09:16 UTC
(In reply to Jakub Jelinek from comment #2)
> Started with r254167, so maybe related to PR84251.

Yes, it is the same issue. As said in PR84251, we have to wrap COMPARE into UNSPEC, so this defeats some passes (in this case fwprop1 pass) that look at RTX code of the pattern.
Comment 4 Jakub Jelinek 2018-07-26 11:23:59 UTC
GCC 8.2 has been released.
Comment 5 Jeffrey A. Law 2018-12-06 04:25:43 UTC
Per c#3.

*** This bug has been marked as a duplicate of bug 84251 ***