1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // Don't include mm_malloc.h, it's system specific. 4*f4a2713aSLionel Sambuc #define __MM_MALLOC_H 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc #include <immintrin.h> 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc // 9*f4a2713aSLionel Sambuc // Test LLVM IR codegen of shuffle instructions 10*f4a2713aSLionel Sambuc // 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc __m256 x(__m256 a, __m256 b) { 13*f4a2713aSLionel Sambuc // Check if the mask is correct 14*f4a2713aSLionel Sambuc // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 8, i32 11, i32 7, i32 6, i32 12, i32 15> 15*f4a2713aSLionel Sambuc return _mm256_shuffle_ps(a, b, 203); 16*f4a2713aSLionel Sambuc } 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc __m128d test_mm_permute_pd(__m128d a) { 19*f4a2713aSLionel Sambuc // Check if the mask is correct 20*f4a2713aSLionel Sambuc // CHECK: shufflevector{{.*}}<i32 1, i32 0> 21*f4a2713aSLionel Sambuc return _mm_permute_pd(a, 1); 22*f4a2713aSLionel Sambuc } 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc __m256d test_mm256_permute_pd(__m256d a) { 25*f4a2713aSLionel Sambuc // Check if the mask is correct 26*f4a2713aSLionel Sambuc // CHECK: shufflevector{{.*}}<i32 1, i32 0, i32 3, i32 2> 27*f4a2713aSLionel Sambuc return _mm256_permute_pd(a, 5); 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc __m128 test_mm_permute_ps(__m128 a) { 31*f4a2713aSLionel Sambuc // Check if the mask is correct 32*f4a2713aSLionel Sambuc // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 1, i32 0> 33*f4a2713aSLionel Sambuc return _mm_permute_ps(a, 0x1b); 34*f4a2713aSLionel Sambuc } 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc // Test case for PR12401 37*f4a2713aSLionel Sambuc __m128 test_mm_permute_ps2(__m128 a) { 38*f4a2713aSLionel Sambuc // Check if the mask is correct 39*f4a2713aSLionel Sambuc // CHECK: shufflevector{{.*}}<i32 2, i32 1, i32 2, i32 3> 40*f4a2713aSLionel Sambuc return _mm_permute_ps(a, 0xe6); 41*f4a2713aSLionel Sambuc } 42*f4a2713aSLionel Sambuc 43*f4a2713aSLionel Sambuc __m256 test_mm256_permute_ps(__m256 a) { 44*f4a2713aSLionel Sambuc // Check if the mask is correct 45*f4a2713aSLionel Sambuc // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4> 46*f4a2713aSLionel Sambuc return _mm256_permute_ps(a, 0x1b); 47*f4a2713aSLionel Sambuc } 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambuc __m256d test_mm256_permute2f128_pd(__m256d a, __m256d b) { 50*f4a2713aSLionel Sambuc // Check if the mask is correct 51*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.avx.vperm2f128.pd.256 52*f4a2713aSLionel Sambuc return _mm256_permute2f128_pd(a, b, 0x31); 53*f4a2713aSLionel Sambuc } 54*f4a2713aSLionel Sambuc 55*f4a2713aSLionel Sambuc __m256 test_mm256_permute2f128_ps(__m256 a, __m256 b) { 56*f4a2713aSLionel Sambuc // Check if the mask is correct 57*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.avx.vperm2f128.ps.256 58*f4a2713aSLionel Sambuc return _mm256_permute2f128_ps(a, b, 0x13); 59*f4a2713aSLionel Sambuc } 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambuc __m256i test_mm256_permute2f128_si256(__m256i a, __m256i b) { 62*f4a2713aSLionel Sambuc // Check if the mask is correct 63*f4a2713aSLionel Sambuc // CHECK: @llvm.x86.avx.vperm2f128.si.256 64*f4a2713aSLionel Sambuc return _mm256_permute2f128_si256(a, b, 0x20); 65*f4a2713aSLionel Sambuc } 66