147 lines · c
1// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s2// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s3// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s4// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s5 6// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s7// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s8// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s9// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bitalg -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s10 11 12#include <immintrin.h>13#include "builtin_test_helpers.h"14 15__m256i test_mm256_popcnt_epi16(__m256i __A) {16 // CHECK-LABEL: test_mm256_popcnt_epi1617 // CHECK: @llvm.ctpop.v16i1618 return _mm256_popcnt_epi16(__A);19}20TEST_CONSTEXPR(match_v16hi(_mm256_popcnt_epi16((__m256i)(__v16hi){+5, -3, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129, +511, +1025}), 2, 15, 14, 1, 0, 8, 1, 9, 2, 2, 4, 2, 6, 2, 9, 2));21 22__m256i test_mm256_mask_popcnt_epi16(__m256i __A, __mmask16 __U, __m256i __B) {23 // CHECK-LABEL: test_mm256_mask_popcnt_epi1624 // CHECK: @llvm.ctpop.v16i1625 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}26 return _mm256_mask_popcnt_epi16(__A, __U, __B);27}28TEST_CONSTEXPR(match_v16hi(_mm256_mask_popcnt_epi16(_mm256_set1_epi16(-1), 0xF0F0, (__m256i)(__v16hi){+5, -3, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129, +511, +1025}), -1, -1, -1, -1, 0, 8, 1, 9, -1, -1, -1, -1, 6, 2, 9, 2));29 30__m256i test_mm256_maskz_popcnt_epi16(__mmask16 __U, __m256i __B) {31 // CHECK-LABEL: test_mm256_maskz_popcnt_epi1632 // CHECK: @llvm.ctpop.v16i1633 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}34 return _mm256_maskz_popcnt_epi16(__U, __B);35}36TEST_CONSTEXPR(match_v16hi(_mm256_maskz_popcnt_epi16(0x0F0F, (__m256i)(__v16hi){+5, -3, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129, +511, +1025}), 2, 15, 14, 1, 0, 0, 0, 0, 2, 2, 4, 2, 0, 0, 0, 0));37 38__m128i test_mm_popcnt_epi16(__m128i __A) {39 // CHECK-LABEL: test_mm_popcnt_epi1640 // CHECK: @llvm.ctpop.v8i1641 return _mm_popcnt_epi16(__A);42}43TEST_CONSTEXPR(match_v8hi(_mm_popcnt_epi16((__m128i)(__v8hi){+5, -3, -10, +8, 0, -256, +256, -128}), 2, 15, 14, 1, 0, 8, 1, 9));44 45__m128i test_mm_mask_popcnt_epi16(__m128i __A, __mmask8 __U, __m128i __B) {46 // CHECK-LABEL: test_mm_mask_popcnt_epi1647 // CHECK: @llvm.ctpop.v8i1648 // CHECK: select <8 x i1> %{{[0-9]+}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}49 return _mm_mask_popcnt_epi16(__A, __U, __B);50}51TEST_CONSTEXPR(match_v8hi(_mm_mask_popcnt_epi16(_mm_set1_epi16(-1), 0xF0, (__m128i)(__v8hi){+5, -3, -10, +8, 0, -256, +256, -128}), -1, -1, -1, -1, 0, 8, 1, 9));52 53__m128i test_mm_maskz_popcnt_epi16(__mmask8 __U, __m128i __B) {54 // CHECK-LABEL: test_mm_maskz_popcnt_epi1655 // CHECK: @llvm.ctpop.v8i1656 // CHECK: select <8 x i1> %{{[0-9]+}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}57 return _mm_maskz_popcnt_epi16(__U, __B);58}59TEST_CONSTEXPR(match_v8hi(_mm_maskz_popcnt_epi16(0x0F, (__m128i)(__v8hi){+5, -3, -10, +8, 0, -256, +256, -128}), 2, 15, 14, 1, 0, 0, 0, 0));60 61__m256i test_mm256_popcnt_epi8(__m256i __A) {62 // CHECK-LABEL: test_mm256_popcnt_epi863 // CHECK: @llvm.ctpop.v32i864 return _mm256_popcnt_epi8(__A);65}66TEST_CONSTEXPR(match_v32qi(_mm256_popcnt_epi8((__m256i)(__v32qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73, +5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, 0, 4, 1, 4, 2, 2, 4, 2, 6, 2, 4, 3, 2, 7, 6, 1, 0, 4, 1, 4, 2, 2, 4, 2, 6, 2, 4, 3));67 68__m256i test_mm256_mask_popcnt_epi8(__m256i __A, __mmask32 __U, __m256i __B) {69 // CHECK-LABEL: test_mm256_mask_popcnt_epi870 // CHECK: @llvm.ctpop.v32i871 // CHECK: select <32 x i1> %{{[0-9]+}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}72 return _mm256_mask_popcnt_epi8(__A, __U, __B);73}74TEST_CONSTEXPR(match_v32qi(_mm256_mask_popcnt_epi8(_mm256_set1_epi8(-1), 0xF00F, (__m256i)(__v32qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73, +5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1));75 76__m256i test_mm256_maskz_popcnt_epi8(__mmask32 __U, __m256i __B) {77 // CHECK-LABEL: test_mm256_maskz_popcnt_epi878 // CHECK: @llvm.ctpop.v32i879 // CHECK: select <32 x i1> %{{[0-9]+}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}80 return _mm256_maskz_popcnt_epi8(__U, __B);81}82TEST_CONSTEXPR(match_v32qi(_mm256_maskz_popcnt_epi8(0x0FF0, (__m256i)(__v32qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73, +5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 0, 0, 0, 0, 0, 4, 1, 4, 2, 2, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));83 84__m128i test_mm_popcnt_epi8(__m128i __A) {85 // CHECK-LABEL: test_mm_popcnt_epi886 // CHECK: @llvm.ctpop.v16i887 return _mm_popcnt_epi8(__A);88}89TEST_CONSTEXPR(match_v16qi(_mm_popcnt_epi8((__m128i)(__v16qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, 0, 4, 1, 4, 2, 2, 4, 2, 6, 2, 4, 3));90 91__m128i test_mm_mask_popcnt_epi8(__m128i __A, __mmask16 __U, __m128i __B) {92 // CHECK-LABEL: test_mm_mask_popcnt_epi893 // CHECK: @llvm.ctpop.v16i894 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}95 return _mm_mask_popcnt_epi8(__A, __U, __B);96}97TEST_CONSTEXPR(match_v16qi(_mm_mask_popcnt_epi8(_mm_set1_epi8(-1), 0xF00F, (__m128i)(__v16qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 2, 7, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, 4, 3));98 99__m128i test_mm_maskz_popcnt_epi8(__mmask16 __U, __m128i __B) {100 // CHECK-LABEL: test_mm_maskz_popcnt_epi8101 // CHECK: @llvm.ctpop.v16i8102 // CHECK: select <16 x i1> %{{[0-9]+}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}103 return _mm_maskz_popcnt_epi8(__U, __B);104}105TEST_CONSTEXPR(match_v16qi(_mm_maskz_popcnt_epi8(0x0FF0, (__m128i)(__v16qi){+5, -3, -10, +8, 0, -16, +16, -16, +3, +9, +15, +33, +63, +33, +53, +73}), 0, 0, 0, 0, 0, 4, 1, 4, 2, 2, 4, 2, 0, 0, 0, 0));106 107__mmask32 test_mm256_mask_bitshuffle_epi64_mask(__mmask32 __U, __m256i __A, __m256i __B) {108 // CHECK-LABEL: test_mm256_mask_bitshuffle_epi64_mask109 // CHECK: @llvm.x86.avx512.vpshufbitqmb.256110 // CHECK: and <32 x i1> %{{.*}}, %{{.*}}111 return _mm256_mask_bitshuffle_epi64_mask(__U, __A, __B);112}113 114__mmask32 test_mm256_bitshuffle_epi64_mask(__m256i __A, __m256i __B) {115 // CHECK-LABEL: test_mm256_bitshuffle_epi64_mask116 // CHECK: @llvm.x86.avx512.vpshufbitqmb.256117 return _mm256_bitshuffle_epi64_mask(__A, __B);118}119TEST_CONSTEXPR(_mm256_bitshuffle_epi64_mask(120 (__m256i)(__v32qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128, -1,0,0,0,0,0,0,0, 85,85,85,85,85,85,85,85},121 (__m256i)(__v32qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56, 0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7}) == 0x55ff0101);122 123TEST_CONSTEXPR(_mm256_mask_bitshuffle_epi64_mask(0xFFFF0000,124 (__m256i)(__v32qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128, -1,0,0,0,0,0,0,0, 85,85,85,85,85,85,85,85},125 (__m256i)(__v32qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56, 0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7}) == 0x55ff0000);126 127__mmask16 test_mm_mask_bitshuffle_epi64_mask(__mmask16 __U, __m128i __A, __m128i __B) {128 // CHECK-LABEL: test_mm_mask_bitshuffle_epi64_mask129 // CHECK: @llvm.x86.avx512.vpshufbitqmb.128130 // CHECK: and <16 x i1> %{{.*}}, %{{.*}}131 return _mm_mask_bitshuffle_epi64_mask(__U, __A, __B);132}133 134__mmask16 test_mm_bitshuffle_epi64_mask(__m128i __A, __m128i __B) {135 // CHECK-LABEL: test_mm_bitshuffle_epi64_mask136 // CHECK: @llvm.x86.avx512.vpshufbitqmb.128137 return _mm_bitshuffle_epi64_mask(__A, __B);138}139TEST_CONSTEXPR(_mm_bitshuffle_epi64_mask(140 (__m128i)(__v16qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128},141 (__m128i)(__v16qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56}) == 0x0101);142 143TEST_CONSTEXPR(_mm_mask_bitshuffle_epi64_mask(0xFF00,144 (__m128i)(__v16qi){1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-128},145 (__m128i)(__v16qi){0,1,2,3,4,5,6,7, 63,62,61,60,59,58,57,56}) == 0x0100);146 147