• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +ssse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
2 
3 
4 #include <immintrin.h>
5 
6 // NOTE: This should match the tests in llvm/test/CodeGen/X86/ssse3-intrinsics-fast-isel.ll
7 
test_mm_abs_epi8(__m128i a)8 __m128i test_mm_abs_epi8(__m128i a) {
9   // CHECK-LABEL: test_mm_abs_epi8
10   // CHECK: [[ABS:%.*]] = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %{{.*}}, i1 false)
11   return _mm_abs_epi8(a);
12 }
13 
test_mm_abs_epi16(__m128i a)14 __m128i test_mm_abs_epi16(__m128i a) {
15   // CHECK-LABEL: test_mm_abs_epi16
16   // CHECK: [[ABS:%.*]] = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %{{.*}}, i1 false)
17   return _mm_abs_epi16(a);
18 }
19 
test_mm_abs_epi32(__m128i a)20 __m128i test_mm_abs_epi32(__m128i a) {
21   // CHECK-LABEL: test_mm_abs_epi32
22   // CHECK: [[ABS:%.*]] = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %{{.*}}, i1 false)
23   return _mm_abs_epi32(a);
24 }
25 
test_mm_alignr_epi8(__m128i a,__m128i b)26 __m128i test_mm_alignr_epi8(__m128i a, __m128i b) {
27   // CHECK-LABEL: test_mm_alignr_epi8
28   // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i32> <i32 2, i32 3, i32 4, 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>
29   return _mm_alignr_epi8(a, b, 2);
30 }
31 
test2_mm_alignr_epi8(__m128i a,__m128i b)32 __m128i test2_mm_alignr_epi8(__m128i a, __m128i b) {
33   // CHECK-LABEL: test2_mm_alignr_epi8
34   // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> zeroinitializer, <16 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>
35   return _mm_alignr_epi8(a, b, 17);
36 }
37 
test_mm_hadd_epi16(__m128i a,__m128i b)38 __m128i test_mm_hadd_epi16(__m128i a, __m128i b) {
39   // CHECK-LABEL: test_mm_hadd_epi16
40   // CHECK: call <8 x i16> @llvm.x86.ssse3.phadd.w.128(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
41   return _mm_hadd_epi16(a, b);
42 }
43 
test_mm_hadd_epi32(__m128i a,__m128i b)44 __m128i test_mm_hadd_epi32(__m128i a, __m128i b) {
45   // CHECK-LABEL: test_mm_hadd_epi32
46   // CHECK: call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
47   return _mm_hadd_epi32(a, b);
48 }
49 
test_mm_hadds_epi16(__m128i a,__m128i b)50 __m128i test_mm_hadds_epi16(__m128i a, __m128i b) {
51   // CHECK-LABEL: test_mm_hadds_epi16
52   // CHECK: call <8 x i16> @llvm.x86.ssse3.phadd.sw.128(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
53   return _mm_hadds_epi16(a, b);
54 }
55 
test_mm_hsub_epi16(__m128i a,__m128i b)56 __m128i test_mm_hsub_epi16(__m128i a, __m128i b) {
57   // CHECK-LABEL: test_mm_hsub_epi16
58   // CHECK: call <8 x i16> @llvm.x86.ssse3.phsub.w.128(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
59   return _mm_hsub_epi16(a, b);
60 }
61 
test_mm_hsub_epi32(__m128i a,__m128i b)62 __m128i test_mm_hsub_epi32(__m128i a, __m128i b) {
63   // CHECK-LABEL: test_mm_hsub_epi32
64   // CHECK: call <4 x i32> @llvm.x86.ssse3.phsub.d.128(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
65   return _mm_hsub_epi32(a, b);
66 }
67 
test_mm_hsubs_epi16(__m128i a,__m128i b)68 __m128i test_mm_hsubs_epi16(__m128i a, __m128i b) {
69   // CHECK-LABEL: test_mm_hsubs_epi16
70   // CHECK: call <8 x i16> @llvm.x86.ssse3.phsub.sw.128(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
71   return _mm_hsubs_epi16(a, b);
72 }
73 
test_mm_maddubs_epi16(__m128i a,__m128i b)74 __m128i test_mm_maddubs_epi16(__m128i a, __m128i b) {
75   // CHECK-LABEL: test_mm_maddubs_epi16
76   // CHECK: call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
77   return _mm_maddubs_epi16(a, b);
78 }
79 
test_mm_mulhrs_epi16(__m128i a,__m128i b)80 __m128i test_mm_mulhrs_epi16(__m128i a, __m128i b) {
81   // CHECK-LABEL: test_mm_mulhrs_epi16
82   // CHECK: call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
83   return _mm_mulhrs_epi16(a, b);
84 }
85 
test_mm_shuffle_epi8(__m128i a,__m128i b)86 __m128i test_mm_shuffle_epi8(__m128i a, __m128i b) {
87   // CHECK-LABEL: test_mm_shuffle_epi8
88   // CHECK: call <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
89   return _mm_shuffle_epi8(a, b);
90 }
91 
test_mm_sign_epi8(__m128i a,__m128i b)92 __m128i test_mm_sign_epi8(__m128i a, __m128i b) {
93   // CHECK-LABEL: test_mm_sign_epi8
94   // CHECK: call <16 x i8> @llvm.x86.ssse3.psign.b.128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
95   return _mm_sign_epi8(a, b);
96 }
97 
test_mm_sign_epi16(__m128i a,__m128i b)98 __m128i test_mm_sign_epi16(__m128i a, __m128i b) {
99   // CHECK-LABEL: test_mm_sign_epi16
100   // CHECK: call <8 x i16> @llvm.x86.ssse3.psign.w.128(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
101   return _mm_sign_epi16(a, b);
102 }
103 
test_mm_sign_epi32(__m128i a,__m128i b)104 __m128i test_mm_sign_epi32(__m128i a, __m128i b) {
105   // CHECK-LABEL: test_mm_sign_epi32
106   // CHECK: call <4 x i32> @llvm.x86.ssse3.psign.d.128(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
107   return _mm_sign_epi32(a, b);
108 }
109