<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 convert (x&1) bittest to a shift to drive a blendvps"
   href="https://bugs.llvm.org/show_bug.cgi?id=46531">46531</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][SSE] Failure to convert (x&1) bittest to a shift to drive a blendvps
          </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, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://c.godbolt.org/z/cvDB4B">https://c.godbolt.org/z/cvDB4B</a>

#include <x86intrin.h>

inline unsigned opt(unsigned x, unsigned y) {
    unsigned val = x | y;
    if (y & 1) { val = x ^ y; }
    return val;
}

void opt( unsigned * __restrict dst, const unsigned *x, const unsigned *y )
{
    *dst++ = opt(*x++, *y++);
    *dst++ = opt(*x++, *y++);
    *dst++ = opt(*x++, *y++);
    *dst++ = opt(*x++, *y++);
}

.LCPI0_0:
        .long   1                       # 0x1
opt:
        vmovdqu (%rdx), %xmm1
        vpbroadcastd    .LCPI0_0(%rip), %xmm3 # xmm3 = [1,1,1,1]
        vmovdqu (%rsi), %xmm0
        vpxor   %xmm4, %xmm4, %xmm4
        vpand   %xmm3, %xmm1, %xmm3
        vpor    %xmm0, %xmm1, %xmm2
        vpxor   %xmm0, %xmm1, %xmm0
        vpcmpeqd        %xmm4, %xmm3, %xmm3
        vblendvps       %xmm3, %xmm2, %xmm0, %xmm0
        vmovups %xmm0, (%rdi)
        retq

but we should be able to replace the vpcmpeqd(vpand(y, 1), 0) with vpslli(y,31)
to drive the vblendvps (with inverted selections):

opt:
        vmovdqu (%rdx), %xmm1
        vmovdqu (%rsi), %xmm0
        vpslld  $31, %xmm1, %xmm3
        vpor    %xmm0, %xmm1, %xmm2
        vpxor   %xmm0, %xmm1, %xmm0
        vblendvps       %xmm3, %xmm0, %xmm2, %xmm0
        vmovups %xmm0, (%rdi)
        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>