<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Possibly missed optimization (performance and code size) when comparing floats as raw binary"
   href="https://bugs.llvm.org/show_bug.cgi?id=36260">36260</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Possibly missed optimization (performance and code size) when comparing floats as raw binary
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kobalicek.petr@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code
------------------

#include <stdint.h>
#include <xmmintrin.h>
#include <emmintrin.h>

union F64 {
  double d;
  uint64_t u;
};

uint32_t compareBin(double a, double b) noexcept {
  F64 a_ = { a };
  F64 b_ = { b };
  return a_.u == b_.u;
}

uint32_t compareDbl(double a, double b) noexcept {
  return a == b;
}


Compiles to (-O2 -mavx2 -fno-math-errno):
-----------------------------------------

compareBin(double, double): # @compareBin(double, double)
  vmovq rcx, xmm0
  vmovq rdx, xmm1
  xor eax, eax
  cmp rcx, rdx
  sete al
  ret

compareDbl(double, double): # @compareDbl(double, double)
  vcmpeqsd xmm0, xmm0, xmm1
  vmovq rax, xmm0
  and eax, 1
  ret


I think the `compareBin` should use the same approach as `compareDbl`, which
would be:

compareBin(double, double):
  vpcmpeqq xmm0, xmm0, xmm1
  vmovq rax, xmm0
  and eax, 1
  ret</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>