<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 --- - confusing return from _mm_extract_epi8() in smmintrin.h"
   href="http://llvm.org/bugs/show_bug.cgi?id=17300">17300</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>confusing return from _mm_extract_epi8() in smmintrin.h
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.3
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>vvsed@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>_mm_extract_epi8() function in smmintrin.h returns unsigned char instead of
int.
It is confusing because the corresponding PEXTRB instruction returns ***zero
extended*** int/__int64 value.

In smmintrin.h of GNU C "(unsigned char)" is redundant:

extern __inline int __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_extract_epi8 (__m128i __X, const int __N)
{
   return (unsigned char) __builtin_ia32_vec_ext_v16qi ((__v16qi)__X, __N);
}

While smmintrin.h of Intel C contains:

extern int   __ICL_INTRINCC _mm_extract_epi8 (__m128i, const int);

The corresponding instruction is:
PEXTRB reg/m8, xmm2, imm8

It's Intel description:
Extract a byte integer value from xmm2 at the
source byte offset specified by imm8 into reg
or m8. ***The upper bits of r32 or r64 are zeroed***.</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>