<html>
    <head>
      <base href="http://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 --- - x86 backend: bug in shift of vector elements"
   href="http://llvm.org/bugs/show_bug.cgi?id=16360">16360</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>x86 backend: bug in shift of vector elements
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ili.filippov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10698" name="attach_10698" title="Reproducer of the fail">attachment 10698</a> <a href="attachment.cgi?id=10698&action=edit" title="Reproducer of the fail">[details]</a></span>
Reproducer of the fail

Clang on x86 has an error on attached test if we compile it with -O0 and -m32
(for -msse4 or -mavx targets).
Result is:
sum = 0
TTT1 = 3ffffffffc000000, 3ffffffffc000000, 3ffffffffc000000, 3ffffffffc000000
TTT2 = fffffffffc000000, fffffffffc000000, fffffffffc000000, fffffffffc000000
But TTT1 TTT2 should be the same.

I suppose that problem is in code generation, because llvm representation of
TTT1 TTT2 differ reasonable (only one number, which is different in the source
and should not affect the result).

But their asm representations differ a lot:
If we compile with:
clang -m32 -O0 foo.c -S -mavx
we will have for TTT1:
        movl    136(%esp), %ecx
        movl    %ecx, %edx
        sarl    $31, %edx
        shrl    %edx
        orl     $1073741823, %edx       # imm = 0x3FFFFFFF
        shrl    %ecx
        orl     $-67108864, %ecx        # imm = 0xFFFFFFFFFC000000
        vmovd   %ecx, %xmm0
        vpinsrd $1, %edx, %xmm0, %xmm0
and for TTT2:
        movl    136(%esp), %ecx
        shrl    $2, %ecx
        orl     $-67108864, %ecx        # imm = 0xFFFFFFFFFC000000
        movl    $-1, %edx
        vmovd   %ecx, %xmm0
        vpinsrd $1, %edx, %xmm0, %xmm0

EDX appears to be different, while it should be the same.</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>