[Bug libstdc++/98612] New: _mm_comieq_sd has wrong semantics

guillaume.piolat at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jan 9 14:46:27 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98612

            Bug ID: 98612
           Summary: _mm_comieq_sd has wrong semantics
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guillaume.piolat at gmail dot com
  Target Milestone: ---

Created attachment 49926
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49926&action=edit
Behaviour with 3 compilers

_mm_comieq_sd has different NaN semantics for different people.

# The Unordered team
- GCC will return 1 for a comparison that involved NaN.
- this maps to the underlying instruction

# The Ordered team
- Intel intrinsics guide says: 

     RETURN ( a[63:0] == b[63:0] ) ? 1 : 0

  which indicates an ordered comparison.

- ICC and clang return 0 for a NaN comparison (see image attachments)


As the x86 "intrinsics" are meant as a portable API (vs "builtins"), I would
suggest it is expected that the same result than clang and ICC is returned.

GCC has the same problem for other intrinsics that don't actually map to the
instruction semantics, such as:

sse2:
  - _mm_comieq_sd
  - _mm_comile_sd
  - _mm_comilt_sd
  - _mm_comineq_sd (instruction is an ordered comparison, but intrinsics is an
unordered comparison)

sse:
  - _mm_comieq_ss
  - _mm_comile_ss
  - _mm_comilt_ss
  - _mm_comineq_ss

I don't know for later instruction sets.


More information about the Gcc-bugs mailing list