<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 - [X86][SSE] Failure to merge scalar float comparison results"
   href="https://bugs.llvm.org/show_bug.cgi?id=51068">51068</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][SSE] Failure to merge scalar float comparison results
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://simd.godbolt.org/z/vWb57hqzx">https://simd.godbolt.org/z/vWb57hqzx</a>

#include <x86intrin.h>

bool cmp2_eq(float x, float y, float z, float w) {
    return (x == y) == (z == w);
}

define zeroext i1 @cmp2_eq(float %0, float %1, float %2, float %3) {
  %5 = fcmp une float %0, %1
  %6 = fcmp oeq float %2, %3
  %7 = xor i1 %5, %6
  ret i1 %7
}

cmp2:
        ucomiss %xmm1, %xmm0
        setp    %al
        setne   %cl
        orb     %al, %cl
        ucomiss %xmm3, %xmm2
        setnp   %dl
        sete    %al
        andb    %dl, %al
        xorb    %cl, %al
        retq

We should be able to use cmpss (or cmpsd for doubles) and merge the results to
reduce fpu->gpr traffic and branch density.

Compare to vectors:

__v4si cmp2_eq(__v4sf x, __v4sf y, __v4sf z, __v4sf w) {
    return (x == y) == (z == w);
}

define <4 x i32> @cmp2_(<4 x float> %0, <4 x float> %1, <4 x float> %2, <4 x
float> %3) {
  %5 = fcmp une <4 x float> %0, %1
  %6 = fcmp oeq <4 x float> %2, %3
  %7 = xor <4 x i1> %6, %5
  %8 = sext <4 x i1> %7 to <4 x i32>
  ret <4 x i32> %8
}

cmp2_:
        cmpneqps        %xmm1, %xmm0
        cmpeqps %xmm3, %xmm2
        xorps   %xmm2, %xmm0
        retq</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>