<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 --- - avx2 gather_epi64 intrinsics have wrong pointer type"
   href="http://llvm.org/bugs/show_bug.cgi?id=17312">17312</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>avx2 gather_epi64 intrinsics have wrong pointer type
          </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>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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>agner@agner.org
          </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>The definition of the following intrinsics in avx2intrin.h is problematic:

_mm_i32gather_epi64
_mm256_i32gather_epi64
_mm_i64gather_epi64
_mm256_i64gather_epi64
_mm_mask_i32gather_epi64
_mm256_mask_i32gather_epi64
_mm_mask_i64gather_epi64
_mm256_mask_i64gather_epi64

The base pointer for these intrinsics (named m in clang version of
avx2intrin.h) has type int const *. This is in accordance with the official
Intel documents, which are wrong. The correct type is a pointer to 64-bit
integers. Intel and Microsoft versions of this intrinsic use the type const
__int64 *, which is not defined in any C standard. The Gnu compiler uses the
type const long long *. I would recommend using the type const long long * for
the sake of compatibility with the Gnu compiler.

See gcc patch:
<a href="http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01793/avx2.gatherdecls.gcc.patch">http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01793/avx2.gatherdecls.gcc.patch</a>

Test case:

typedef const long long * ppp;
// typedef const int * ppp;

__m128i VPGATHERDQ1(ppp base, __m128i index) {
   return _mm_i32gather_epi64 (base, index, 1);
}

__m256i VPGATHERDQ2 (ppp base, __m128i index) {
   return _mm256_i32gather_epi64 (base, index, 2);
}

__m128i VPGATHERQQ1(ppp base, __m128i index) {
   return _mm_i64gather_epi64 (base, index, 4);
}

__m128i VPGATHERQQ2(ppp base, __m128i index) {
   return _mm256_i64gather_epi64 ( base,  index, 8);
}</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>