[cfe-commits] r147047 - in /cfe/trunk: include/clang/Basic/BuiltinsX86.def lib/Headers/avx2intrin.h test/CodeGen/avx2-builtins.c
Craig Topper
craig.topper at gmail.com
Wed Dec 21 00:17:40 PST 2011
Author: ctopper
Date: Wed Dec 21 02:17:40 2011
New Revision: 147047
URL: http://llvm.org/viewvc/llvm-project?rev=147047&view=rev
Log:
Add AVX2 horizontal add/sub intrinsics.
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=147047&r1=147046&r2=147047&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Dec 21 02:17:40 2011
@@ -494,5 +494,11 @@
BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "")
BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "")
BUILTIN(__builtin_ia32_pblendw256, "V16sV16sV16sIi", "")
+BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "")
+BUILTIN(__builtin_ia32_phaddd256, "V8iV8iV8i", "")
+BUILTIN(__builtin_ia32_phaddsw256, "V16sV16sV16s", "")
+BUILTIN(__builtin_ia32_phsubw256, "V16sV16sV16s", "")
+BUILTIN(__builtin_ia32_phsubd256, "V8iV8iV8i", "")
+BUILTIN(__builtin_ia32_phsubsw256, "V16sV16sV16s", "")
#undef BUILTIN
Modified: cfe/trunk/lib/Headers/avx2intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=147047&r1=147046&r2=147047&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/avx2intrin.h (original)
+++ cfe/trunk/lib/Headers/avx2intrin.h Wed Dec 21 02:17:40 2011
@@ -208,6 +208,42 @@
}
static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
+_mm256_hadd_epi16(__m256i a, __m256i b)
+{
+ return (__m256i)__builtin_ia32_phaddw256((__v16hi)a, (__v16hi)b);
+}
+
+static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
+_mm256_hadd_epi32(__m256i a, __m256i b)
+{
+ return (__m256i)__builtin_ia32_phaddd256((__v8si)a, (__v8si)b);
+}
+
+static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
+_mm256_hadds_epi16(__m256i a, __m256i b)
+{
+ return (__m256i)__builtin_ia32_phaddsw256((__v16hi)a, (__v16hi)b);
+}
+
+static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
+_mm256_hsub_epi16(__m256i a, __m256i b)
+{
+ return (__m256i)__builtin_ia32_phsubw256((__v16hi)a, (__v16hi)b);
+}
+
+static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
+_mm256_hsub_epi32(__m256i a, __m256i b)
+{
+ return (__m256i)__builtin_ia32_phsubd256((__v8si)a, (__v8si)b);
+}
+
+static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
+_mm256_hsubs_epi16(__m256i a, __m256i b)
+{
+ return (__m256i)__builtin_ia32_phsubsw256((__v16hi)a, (__v16hi)b);
+}
+
+static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
_mm256_or_si256(__m256i a, __m256i b)
{
return a | b;
Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=147047&r1=147046&r2=147047&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Wed Dec 21 02:17:40 2011
@@ -215,3 +215,33 @@
// CHECK: icmp sgt <4 x i64>
return _mm256_cmpgt_epi64(a, b);
}
+
+__m256 test_mm256_hadd_epi16(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.phadd.w
+ return _mm256_hadd_epi16(a, b);
+}
+
+__m256 test_mm256_hadd_epi32(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.phadd.d
+ return _mm256_hadd_epi32(a, b);
+}
+
+__m256 test_mm256_hadds_epi16(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.phadd.sw
+ return _mm256_hadds_epi16(a, b);
+}
+
+__m256 test_mm256_hsub_epi16(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.phsub.w
+ return _mm256_hsub_epi16(a, b);
+}
+
+__m256 test_mm256_hsub_epi32(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.phsub.d
+ return _mm256_hsub_epi32(a, b);
+}
+
+__m256 test_mm256_hsubs_epi16(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.phsub.sw
+ return _mm256_hsubs_epi16(a, b);
+}
More information about the cfe-commits
mailing list