[Bug c++/60237] isnan fails with -ffast-math

nathanael.schaeffer at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Feb 17 11:38:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60237

--- Comment #4 from N Schaeffer <nathanael.schaeffer at gmail dot com> ---
int my_isnan(double x){
  volatile double y=x;
  return y!=y;
}

is translated to:
   0x0000000000406cf0 <+0>:     movsd  QWORD PTR [rsp-0x8],xmm0
   0x0000000000406cf6 <+6>:     xor    eax,eax
   0x0000000000406cf8 <+8>:     movsd  xmm1,QWORD PTR [rsp-0x8]
   0x0000000000406cfe <+14>:    movsd  xmm0,QWORD PTR [rsp-0x8]
   0x0000000000406d04 <+20>:    comisd xmm1,xmm0
   0x0000000000406d08 <+24>:    setne  al
   0x0000000000406d0b <+27>:    ret

which also fails to detect NaN, which is right according to the documented
behaviour of comisd:
http://www.jaist.ac.jp/iscenter-new/mpc/altix/altixdata/opt/intel/vtune/doc/users_guide/mergedProjects/analyzer_ec/mergedProjects/reference_olh/mergedProjects/instructions/instruct32_hh/vc44.htm



More information about the Gcc-bugs mailing list