Sorry about the noise. This one additionaly removes a test that used the 
__builtin_ function.


http://reviews.llvm.org/D7199

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/emmintrin.h
  test/CodeGen/sse.c
  test/Sema/x86-builtin-palignr.c

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: include/clang/Basic/BuiltinsX86.def
===================================================================
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -316,8 +316,6 @@
 BUILTIN(__builtin_ia32_psrad128, "V4iV4iV4i", "")
 BUILTIN(__builtin_ia32_psrlw128, "V8sV8sV8s", "")
 BUILTIN(__builtin_ia32_psrld128, "V4iV4iV4i", "")
-BUILTIN(__builtin_ia32_pslldqi128, "V2LLiV2LLiIi", "")
-BUILTIN(__builtin_ia32_psrldqi128, "V2LLiV2LLiIi", "")
 BUILTIN(__builtin_ia32_psrlq128, "V2LLiV2LLiV2LLi", "")
 BUILTIN(__builtin_ia32_psllw128, "V8sV8sV8s", "")
 BUILTIN(__builtin_ia32_pslld128, "V4iV4iV4i", "")
Index: lib/Headers/emmintrin.h
===================================================================
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -825,11 +825,31 @@
   return __a ^ __b;
 }
 
-#define _mm_slli_si128(a, count) __extension__ ({ \
-  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \
-  __m128i __a = (a); \
-   _Pragma("clang diagnostic pop"); \
-  (__m128i)__builtin_ia32_pslldqi128(__a, (count)*8); })
+#define _mm_slli_si128(a, imm)                                                 \
+  __extension__({                                                              \
+    _Pragma("clang diagnostic push")                                           \
+        _Pragma("clang diagnostic ignored \"-Wshadow\"");                      \
+    __m128i __a = (a);                                                         \
+    _Pragma("clang diagnostic pop");                                           \
+    (__m128i)                                                                  \
+        __builtin_shufflevector((__v16qi)_mm_setzero_si128(), (__v16qi)__a,    \
+                                ((imm)&0xF0) ? 0 : 16 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 17 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 18 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 19 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 20 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 21 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 22 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 23 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 24 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 25 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 26 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 27 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 28 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 29 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 30 - ((imm)&0xF),           \
+                                ((imm)&0xF0) ? 0 : 31 - ((imm)&0xF));          \
+  })
 
 static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
 _mm_slli_epi16(__m128i __a, int __count)
@@ -891,12 +911,31 @@
   return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count);
 }
 
-
-#define _mm_srli_si128(a, count) __extension__ ({ \
-  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \
-  __m128i __a = (a); \
-  _Pragma("clang diagnostic pop"); \
-  (__m128i)__builtin_ia32_psrldqi128(__a, (count)*8); })
+#define _mm_srli_si128(a, imm)                                                 \
+  __extension__({                                                              \
+    _Pragma("clang diagnostic push")                                           \
+        _Pragma("clang diagnostic ignored \"-Wshadow\"");                      \
+    __m128i __a = (a);                                                         \
+    _Pragma("clang diagnostic pop");                                           \
+    (__m128i)                                                                  \
+        __builtin_shufflevector((__v16qi)__a, (__v16qi)_mm_setzero_si128(),    \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 0,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 1,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 2,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 3,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 4,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 5,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 6,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 7,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 8,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 9,           \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 10,          \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 11,          \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 12,          \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 13,          \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 14,          \
+                                ((imm)&0xF0) ? 16 : ((imm)&0xF) + 15);         \
+  })
 
 static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
 _mm_srli_epi16(__m128i __a, int __count)
Index: test/CodeGen/sse.c
===================================================================
--- /dev/null
+++ test/CodeGen/sse.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -O3 -ffreestanding -triple x86_64-apple-macosx10.8.0 -target-feature +sse4.1 -emit-llvm %s -o - | FileCheck %s
+
+#include <emmintrin.h>
+
+// Byte-shifts look reversed due to xmm register layout
+__m128 test_mm_slli_si128(__m128 a) {
+  // CHECK-LABEL: @test_mm_slli_si128
+  // CHECK: shufflevector <16 x i8> <{{.*}}, i8 0, i8 0, i8 0, i8 0, i8 0>, <16 x i8> {{.*}}, <16 x i32> <i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26>
+  return _mm_slli_si128(a, 5);
+}
+
+__m128 test_mm_slli_si128_0(__m128 a) {
+  // CHECK-LABEL: @test_mm_slli_si128_0
+  // CHECK-NOT: shufflevector
+  return _mm_slli_si128(a, 0);
+}
+
+__m128 test_mm_slli_si128_16(__m128 a) {
+  // CHECK-LABEL: @test_mm_slli_si128_16
+  // CHECK-NOT: shufflevector
+  return _mm_slli_si128(a, 16);
+}
+
+__m128 test_mm_srli_si128(__m128 a) {
+  // CHECK-LABEL: @test_mm_srli_si128
+  // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, {{.*}}>, <16 x i32> <i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20>
+  return _mm_srli_si128(a, 5);
+}
+
+__m128 test_mm_srli_si128_0(__m128 a) {
+  // CHECK-LABEL: @test_mm_srli_si128_0
+  // CHECK-NOT: shufflevector
+  return _mm_srli_si128(a, 0);
+}
+
+__m128 test_mm_srli_si128_16(__m128 a) {
+  // CHECK-LABEL: @test_mm_srli_si128_16
+  // CHECK-NOT: shufflevector
+  return _mm_srli_si128(a, 16);
+}
Index: test/Sema/x86-builtin-palignr.c
===================================================================
--- test/Sema/x86-builtin-palignr.c
+++ test/Sema/x86-builtin-palignr.c
@@ -8,10 +8,3 @@
    // be removed when that is fixed.
    return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
 }
-
-int test2(int N) {
- __m128i white2;
- white2 = __builtin_ia32_pslldqi128(white2, N); // expected-error {{argument to '__builtin_ia32_pslldqi128' must be a constant integer}}
- return 0;
-} 
-
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to