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
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2018-07-11 21:39 UTC by ead
Modified: 2018-12-06 04:25 UTC (History)
2 users (show)

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


Attachments

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 

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

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

_Z7is_nan1d:
  ucomisd %xmm0, %xmm0
  setp %al
  ret

Also for 8.1 -Os is the assembler somewhat strange:

_Z7is_nan1d:
  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 ***