<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 - MS Inline assembly with vector type causes a bad trunc emission."
   href="https://bugs.llvm.org/show_bug.cgi?id=34021">34021</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MS Inline assembly with vector type causes a bad trunc emission.
          </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>Windows NT
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>erich.keane@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, rnk@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Code: 
typedef int v4si __attribute__ ((vector_size (16)));
v4si rep() {
    v4si res;
    __asm {}
    return res;
}

Compile with: -O0 -fms-extensions -m32
Result is a crash in DAG due to a trunc that widens instead of narrows.  
Higher optimizer levels cause this to disappear, presumably due to instcombine.

Our original repro:
 #include <emmintrin.h>
 __m128i x;

 __m128i foo ()
 {
      __asm {
          movdqu xmm0, xmm1
      }
     return x;
 }


Also should validate that the following works:
#include <emmintrin.h>
 __m128i x;

 __m128i foo ()
 {
      __asm {
          movdqu xmm0, x
      }
 }

int main () {
    foo();
    return 0;
 }</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>