[cfe-commits] r128984 - in /cfe/trunk: lib/Headers/avxintrin.h test/CodeGen/avx-cmp-builtins.c

John McCall rjmccall at apple.com
Tue Apr 5 20:37:52 PDT 2011


Author: rjmccall
Date: Tue Apr  5 22:37:51 2011
New Revision: 128984

URL: http://llvm.org/viewvc/llvm-project?rev=128984&view=rev
Log:
Implement the AVX cmp builtins as macros instead of static inlines.
Patch by Syoyo Fujita!  Reviewed by Chris Lattner!  Checked in by me!


Added:
    cfe/trunk/test/CodeGen/avx-cmp-builtins.c
Modified:
    cfe/trunk/lib/Headers/avxintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=128984&r1=128983&r2=128984&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Tue Apr  5 22:37:51 2011
@@ -385,41 +385,23 @@
 #define _CMP_GT_OQ    0x1e /* Greater-than (ordered, non-signaling)  */
 #define _CMP_TRUE_US  0x1f /* True (unordered, signaling)  */
 
-static __inline __m128d __attribute__((__always_inline__, __nodebug__))
-_mm_cmp_pd(__m128d a, __m128d b, const int c)
-{
-  return (__m128d)__builtin_ia32_cmppd((__v2df)a, (__v2df)b, c);
-}
+#define _mm_cmp_pd(a, b, c) \
+  (__m128d)__builtin_ia32_cmppd((__v2df)(a), (__v2df)(b), (c))
 
-static __inline __m128 __attribute__((__always_inline__, __nodebug__))
-_mm_cmp_ps(__m128 a, __m128 b, const int c)
-{
-  return (__m128)__builtin_ia32_cmpps((__v4sf)a, (__v4sf)b, c);
-}
+#define _mm_cmp_ps(a, b, c) \
+  (__m128)__builtin_ia32_cmpps((__v4sf)(a), (__v4sf)(b), (c))
 
-static __inline __m256d __attribute__((__always_inline__, __nodebug__))
-_mm256_cmp_pd(__m256d a, __m256d b, const int c)
-{
-  return (__m256d)__builtin_ia32_cmppd256((__v4df)a, (__v4df)b, c);
-}
+#define _mm256_cmp_pd(a, b, c) \
+  (__m256d)__builtin_ia32_cmppd256((__v4df)(a), (__v4df)(b), (c))
 
-static __inline __m256 __attribute__((__always_inline__, __nodebug__))
-_mm256_cmp_ps(__m256 a, __m256 b, const int c)
-{
-  return (__m256)__builtin_ia32_cmpps256((__v8sf)a, (__v8sf)b, c);
-}
+#define _mm256_cmp_ps(a, b, c) \
+  (__m256)__builtin_ia32_cmpps256((__v8sf)(a), (__v8sf)(b), (c))
 
-static __inline __m128d __attribute__((__always_inline__, __nodebug__))
-_mm_cmp_sd(__m128d a, __m128d b, const int c)
-{
-  return (__m128d)__builtin_ia32_cmpsd((__v2df)a, (__v2df)b, c);
-}
+#define _mm_cmp_sd(a, b, c) \
+  (__m128d)__builtin_ia32_cmpsd((__v2df)(a), (__v2df)(b), (c))
 
-static __inline __m128 __attribute__((__always_inline__, __nodebug__))
-_mm_cmp_ss(__m128 a, __m128 b, const int c)
-{
-  return (__m128)__builtin_ia32_cmpss((__v4sf)a, (__v4sf)b, c);
-}
+#define _mm_cmp_ss(a, b, c) \
+  (__m128)__builtin_ia32_cmpss((__v4sf)(a), (__v4sf)(b), (c))
 
 /* Vector extract */
 static __inline __m128d __attribute__((__always_inline__, __nodebug__))

Added: cfe/trunk/test/CodeGen/avx-cmp-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-cmp-builtins.c?rev=128984&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/avx-cmp-builtins.c (added)
+++ cfe/trunk/test/CodeGen/avx-cmp-builtins.c Tue Apr  5 22:37:51 2011
@@ -0,0 +1,47 @@
+// RUN: %clang -mavx -c -emit-llvm %s -o - | llvm-dis | FileCheck %s
+#include <immintrin.h>
+
+//
+// Test if third argument of cmp_XY function in LLVM IR form has immediate value.
+//
+void test_cmp_ps256() {
+    __m256 a, b, c;
+    a = _mm256_cmp_ps(b, c, _CMP_GE_OS);
+    // CHECK: @test_cmp_ps256
+    // CHECK: %0 = call <8 x float> @llvm.x86.avx.cmp.ps.256(<8 x float> %tmp, <8 x float> %tmp1, i8 13)
+}
+
+void test_cmp_pd256() {
+    __m256d a, b, c;
+    a = _mm256_cmp_pd(b, c, _CMP_GE_OS);
+    // CHECK: @test_cmp_pd256
+    // CHECK: %0 = call <4 x double> @llvm.x86.avx.cmp.pd.256(<4 x double> %tmp, <4 x double> %tmp1, i8 13)
+}
+
+void test_cmp_ps() {
+    __m128 a, b, c;
+    a = _mm_cmp_ps(b, c, _CMP_GE_OS);
+    // CHECK: @test_cmp_ps
+    // CHECK: %cmpps = call <4 x float> @llvm.x86.sse.cmp.ps(<4 x float> %tmp, <4 x float> %tmp1, i8 13)
+}
+
+void test_cmp_pd() {
+    __m128d a, b, c;
+    a = _mm_cmp_pd(b, c, _CMP_GE_OS);
+    // CHECK: @test_cmp_pd
+    // CHECK: %cmppd = call <2 x double> @llvm.x86.sse2.cmp.pd(<2 x double> %tmp, <2 x double> %tmp1, i8 13)
+}
+
+void test_cmp_sd() {
+    __m128d a, b, c;
+    a = _mm_cmp_sd(b, c, _CMP_GE_OS);
+    // CHECK: @test_cmp_sd
+    // CHECK: %cmpsd = call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %tmp, <2 x double> %tmp1, i8 13)
+}
+
+void test_cmp_ss() {
+    __m128 a, b, c;
+    a = _mm_cmp_ss(b, c, _CMP_GE_OS);
+    // CHECK: @test_cmp_ss
+    // CHECK: %cmpss = call <4 x float> @llvm.x86.sse.cmp.ss(<4 x float> %tmp, <4 x float> %tmp1, i8 13)
+}





More information about the cfe-commits mailing list