<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 --- - Combining MMX with AVX suboptimal"
   href="https://llvm.org/bugs/show_bug.cgi?id=29222">29222</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Combining MMX with AVX suboptimal
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kobalicek.petr@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>The following code:

#include <mmintrin.h>
#include <immintrin.h>

int fn(int x) {
  __m64 mm = _mm_set1_pi32(x);
  mm = _mm_packs_pi16(mm, mm);

  __m128i xmm = _mm_movpi64_epi64(mm);
  xmm = _mm_packs_epi16(xmm, xmm);
  return _mm_cvtsi128_si32(xmm);
}

Compiled with '-O2 -Wall -mavx2 -m32 -fomit-frame-pointer' produces:

fn(int):
  sub     esp, 20
  vbroadcastss    xmm0, dword ptr [esp + 24] # Cool idea, but not 
  vmovlps qword ptr [esp + 8], xmm0          # in our context.
  movq    mm0, qword ptr [esp + 8]           # !!!
  packsswb        mm0, mm0
  movq    qword ptr [esp], mm0               # These moves are
  vmovq   xmm0, qword ptr [esp]              # correct.
  vpacksswb       xmm0, xmm0, xmm0
  vmovd   eax, xmm0
  add     esp, 20
  ret


I know that MMX is not used anymore, but I wonder why clang prefers a code-path
that is one instruction longer and contains 2 memory accesses more than a more
straightforward 'punpckldq'.</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>