1 // RUN: %clang_cc1 -ffreestanding -O3 -triple x86_64-apple-macosx10.8.0 -target-feature +sse4.1 -emit-llvm %s -o - | FileCheck %s
2 // FIXME: This test currently depends on optimization - it should be rewritten to avoid it.
3 
4 
5 #include <emmintrin.h>
6 
7 // Byte-shifts look reversed due to xmm register layout
test_mm_slli_si128(__m128i a)8 __m128i test_mm_slli_si128(__m128i a) {
9   // CHECK-LABEL: @test_mm_slli_si128
10   // 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>
11   return _mm_slli_si128(a, 5);
12 }
13 
test_mm_slli_si128_0(__m128i a)14 __m128i test_mm_slli_si128_0(__m128i a) {
15   // CHECK-LABEL: @test_mm_slli_si128_0
16   // CHECK-NOT: shufflevector
17   return _mm_slli_si128(a, 0);
18 }
19 
test_mm_slli_si128_16(__m128i a)20 __m128i test_mm_slli_si128_16(__m128i a) {
21   // CHECK-LABEL: @test_mm_slli_si128_16
22   // CHECK-NOT: shufflevector
23   return _mm_slli_si128(a, 16);
24 }
25 
test_mm_srli_si128(__m128i a)26 __m128i test_mm_srli_si128(__m128i a) {
27   // CHECK-LABEL: @test_mm_srli_si128
28   // 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>
29   return _mm_srli_si128(a, 5);
30 }
31 
test_mm_srli_si128_0(__m128i a)32 __m128i test_mm_srli_si128_0(__m128i a) {
33   // CHECK-LABEL: @test_mm_srli_si128_0
34   // CHECK-NOT: shufflevector
35   return _mm_srli_si128(a, 0);
36 }
37 
test_mm_srli_si128_16(__m128i a)38 __m128i test_mm_srli_si128_16(__m128i a) {
39   // CHECK-LABEL: @test_mm_srli_si128_16
40   // CHECK-NOT: shufflevector
41   return _mm_srli_si128(a, 16);
42 }
43