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