<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Wrong mask generated for _mm_blendv_epi8"
   href="https://llvm.org/bugs/show_bug.cgi?id=24532">24532</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong mask generated for _mm_blendv_epi8
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>aivchenk@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14754" name="attach_14754" title="Reprocuder">attachment 14754</a> <a href="attachment.cgi?id=14754&action=edit" title="Reprocuder">[details]</a></span>
Reprocuder

Following code works with gcc and clang -O0, but fails on clang -O1:
_mm_blendv_epi8 produces wrong result in that case.

<span class="quote">>gcc ../blend.cpp -msse4.2 -O2 -o gcc.exe ; ./gcc.exe</span >
finish blend testing
<span class="quote">>clang++ ../blend.cpp -msse4.2 -O0; ./a.out</span >
finish blend testing
<span class="quote">>clang++ ../blend.cpp -msse4.2 -O1; ./a.out</span >
Aborted (core dumped)


I tested trunk so far only, but I suspect the issue affects 3.6 as well.


The problem is with wrong mask generated for pblendvb:

        movdqa  (%rsi), %xmm1
        movaps  .LCPI0_0(%rip), %xmm0   # xmm0 =
[0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255]
        pblendvb        (%rdx), %xmm1
        movdqa  %xmm1, (%rdi)

While the actual mask for the intrinsic was 0xff00000000000000ff000000ff000000</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>