[cfe-commits] r159222 - in /cfe/trunk: include/clang/Basic/BuiltinsX86.def lib/Headers/avx2intrin.h test/CodeGen/avx2-builtins.c
Manman Ren
mren at apple.com
Tue Jun 26 12:55:09 PDT 2012
Author: mren
Date: Tue Jun 26 14:55:09 2012
New Revision: 159222
URL: http://llvm.org/viewvc/llvm-project?rev=159222&view=rev
Log:
X86: add GATHER intrinsics (AVX2) in Clang
Support the following intrinsics:
_mm_mask_i32gather_pd, _mm256_mask_i32gather_pd, _mm_mask_i64gather_pd
_mm256_mask_i64gather_pd, _mm_mask_i32gather_ps, _mm256_mask_i32gather_ps
_mm_mask_i64gather_ps, _mm256_mask_i64gather_ps
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/test/CodeGen/avx2-builtins.c
Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=159222&r1=159221&r2=159222&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Jun 26 14:55:09 2012
@@ -595,6 +595,16 @@
BUILTIN(__builtin_ia32_psrlv4di, "V4LLiV4LLiV4LLi", "")
BUILTIN(__builtin_ia32_psrlv2di, "V2LLiV2LLiV2LLi", "")
+// GATHER
+BUILTIN(__builtin_ia32_gatherd_pd, "V2dV2dV2dC*V4iV2dIc", "")
+BUILTIN(__builtin_ia32_gatherd_pd256, "V4dV4dV4dC*V8iV4dIc", "")
+BUILTIN(__builtin_ia32_gatherq_pd, "V2dV2dV2dC*V2LLiV2dIc", "")
+BUILTIN(__builtin_ia32_gatherq_pd256, "V4dV4dV4dC*V4LLiV4dIc", "")
+BUILTIN(__builtin_ia32_gatherd_ps, "V4fV4fV4fC*V4iV4fIc", "")
+BUILTIN(__builtin_ia32_gatherd_ps256, "V8fV8fV8fC*V8iV8fIc", "")
+BUILTIN(__builtin_ia32_gatherq_ps, "V4fV4fV4fC*V2LLiV4fIc", "")
+BUILTIN(__builtin_ia32_gatherq_ps256, "V8fV8fV8fC*V4LLiV8fIc", "")
+
// BMI
BUILTIN(__builtin_ia32_bextr_u32, "UiUiUi", "")
BUILTIN(__builtin_ia32_bextr_u64, "ULLiULLiULLi", "")
Modified: cfe/trunk/lib/Headers/avx2intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=159222&r1=159221&r2=159222&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/avx2intrin.h (original)
+++ cfe/trunk/lib/Headers/avx2intrin.h Tue Jun 26 14:55:09 2012
@@ -959,3 +959,67 @@
{
return (__m128i)__builtin_ia32_psrlv2di(__X, __Y);
}
+
+#define _mm_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \
+ __m128d __a = (a); \
+ double const *__m = (m); \
+ __m128i __i = (i); \
+ __m128d __mask = (mask); \
+ (__m128d)__builtin_ia32_gatherd_pd((__v2df)__a, (const __v2df *)__m, \
+ (__v4si)__i, (__v2df)__mask, (s)); })
+
+#define _mm256_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \
+ __m256d __a = (a); \
+ double const *__m = (m); \
+ __m256i __i = (i); \
+ __m256d __mask = (mask); \
+ (__m256d)__builtin_ia32_gatherd_pd256((__v4df)__a, (const __v4df *)__m, \
+ (__v8si)__i, (__v4df)__mask, (s)); })
+
+#define _mm_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \
+ __m128d __a = (a); \
+ double const *__m = (m); \
+ __m128i __i = (i); \
+ __m128d __mask = (mask); \
+ (__m128d)__builtin_ia32_gatherq_pd((__v2df)__a, (const __v2df *)__m, \
+ (__v2di)__i, (__v2df)__mask, (s)); })
+
+#define _mm256_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \
+ __m256d __a = (a); \
+ double const *__m = (m); \
+ __m256i __i = (i); \
+ __m256d __mask = (mask); \
+ (__m256d)__builtin_ia32_gatherq_pd256((__v4df)__a, (const __v4df *)__m, \
+ (__v4di)__i, (__v4df)__mask, (s)); })
+
+#define _mm_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \
+ __m128 __a = (a); \
+ float const *__m = (m); \
+ __m128i __i = (i); \
+ __m128 __mask = (mask); \
+ (__m128)__builtin_ia32_gatherd_ps((__v4sf)__a, (const __v4sf *)__m, \
+ (__v4si)__i, (__v4sf)__mask, (s)); })
+
+#define _mm256_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \
+ __m256 __a = (a); \
+ float const *__m = (m); \
+ __m256i __i = (i); \
+ __m256 __mask = (mask); \
+ (__m256)__builtin_ia32_gatherd_ps256((__v8sf)__a, (const __v8sf *)__m, \
+ (__v8si)__i, (__v8sf)__mask, (s)); })
+
+#define _mm_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \
+ __m128 __a = (a); \
+ float const *__m = (m); \
+ __m128i __i = (i); \
+ __m128 __mask = (mask); \
+ (__m128)__builtin_ia32_gatherq_ps((__v4sf)__a, (const __v4sf *)__m, \
+ (__v2di)__i, (__v4sf)__mask, (s)); })
+
+#define _mm256_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \
+ __m256 __a = (a); \
+ float const *__m = (m); \
+ __m256i __i = (i); \
+ __m256 __mask = (mask); \
+ (__m256)__builtin_ia32_gatherq_ps256((__v8sf)__a, (const __v8sf *)__m, \
+ (__v4di)__i, (__v8sf)__mask, (s)); })
Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=159222&r1=159221&r2=159222&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Tue Jun 26 14:55:09 2012
@@ -780,3 +780,46 @@
// CHECK: @llvm.x86.avx2.psrlv.q
return _mm_srlv_epi64(a, b);
}
+
+__m128d test_mm_mask_i32gather_pd(__m128d a, double const *b, __m128i c,
+ __m128d d) {
+ // CHECK: @llvm.x86.avx2.gather.d.pd
+ return _mm_mask_i32gather_pd(a, b, c, d, 2);
+}
+
+__m256d test_mm256_mask_i32gather_pd(__m256d a, double const *b, __m256i c,
+ __m256d d) {
+ // CHECK: @llvm.x86.avx2.gather.d.pd.256
+ return _mm256_mask_i32gather_pd(a, b, c, d, 2);
+}
+__m128d test_mm_mask_i64gather_pd(__m128d a, double const *b, __m128i c,
+ __m128d d) {
+ // CHECK: @llvm.x86.avx2.gather.q.pd
+ return _mm_mask_i64gather_pd(a, b, c, d, 2);
+}
+__m256d test_mm256_mask_i64gather_pd(__m256d a, double const *b, __m256i c,
+ __m256d d) {
+ // CHECK: @llvm.x86.avx2.gather.q.pd.256
+ return _mm256_mask_i64gather_pd(a, b, c, d, 2);
+}
+
+__m128 test_mm_mask_i32gather_ps(__m128 a, float const *b, __m128i c,
+ __m128 d) {
+ // CHECK: @llvm.x86.avx2.gather.d.ps
+ return _mm_mask_i32gather_ps(a, b, c, d, 2);
+}
+__m256 test_mm256_mask_i32gather_ps(__m256 a, float const *b, __m256i c,
+ __m256 d) {
+ // CHECK: @llvm.x86.avx2.gather.d.ps.256
+ return _mm256_mask_i32gather_ps(a, b, c, d, 2);
+}
+__m128 test_mm_mask_i64gather_ps(__m128 a, float const *b, __m128i c,
+ __m128 d) {
+ // CHECK: @llvm.x86.avx2.gather.q.ps
+ return _mm_mask_i64gather_ps(a, b, c, d, 2);
+}
+__m256 test_mm256_mask_i64gather_ps(__m256 a, float const *b, __m256i c,
+ __m256 d) {
+ // CHECK: @llvm.x86.avx2.gather.q.ps.256
+ return _mm256_mask_i64gather_ps(a, b, c, d, 2);
+}
More information about the cfe-commits
mailing list