From 0b9d105a1607fc0b1eebc25ddd06f5b5162fff5d Mon Sep 17 00:00:00 2001 From: Michael Zuckerman Date: Fri, 29 Apr 2016 11:01:16 +0000 Subject: [PATCH] [clang][BuiltIn][AVX512]Adding intrinsics for cmp{ss|sd} instruction set. Differential Revision: http://reviews.llvm.org/D19601 llvm-svn: 268028 --- clang/include/clang/Basic/BuiltinsX86.def | 3 +- clang/lib/Headers/avx512fintrin.h | 52 +++++++++++++++++++++++ clang/test/CodeGen/avx512f-builtins.c | 48 +++++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def index 452f42d1fc92..72a6f830fe94 100644 --- a/clang/include/clang/Basic/BuiltinsX86.def +++ b/clang/include/clang/Basic/BuiltinsX86.def @@ -2222,7 +2222,8 @@ TARGET_BUILTIN(__builtin_ia32_compressdf512_mask, "V8dV8dV8dUc","","avx512f") TARGET_BUILTIN(__builtin_ia32_compressdi512_mask, "V8LLiV8LLiV8LLiUc","","avx512f") TARGET_BUILTIN(__builtin_ia32_compresssf512_mask, "V16fV16fV16fUs","","avx512f") TARGET_BUILTIN(__builtin_ia32_compresssi512_mask, "V16iV16iV16iUs","","avx512f") - +TARGET_BUILTIN(__builtin_ia32_cmpsd_mask, "UcV2dV2dIiUcIi","","avx512f") +TARGET_BUILTIN(__builtin_ia32_cmpss_mask, "UcV4fV4fIiUcIi","","avx512f") #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h index 5b9a45b4bd4d..1270a9b01922 100644 --- a/clang/lib/Headers/avx512fintrin.h +++ b/clang/lib/Headers/avx512fintrin.h @@ -7629,6 +7629,58 @@ _mm512_maskz_compress_epi32 (__mmask16 __U, __m512i __A) (__mmask16) __U); } +#define _mm_cmp_round_ss_mask( __X, __Y, __P, __R) __extension__ ({ \ +__builtin_ia32_cmpss_mask ((__v4sf)( __X),\ + (__v4sf)( __Y), __P,\ + (__mmask8) -1, __R);\ +}) + +#define _mm_mask_cmp_round_ss_mask( __M, __X, __Y, __P, __R) __extension__ ({ \ +__builtin_ia32_cmpss_mask ((__v4sf)( __X),\ + (__v4sf)( __Y), __P,\ + (__mmask8)( __M), __R);\ +}) + +#define _mm_cmp_ss_mask( __X, __Y, __P) __extension__ ({ \ +__builtin_ia32_cmpss_mask ((__v4sf)( __X),\ + (__v4sf)( __Y),( __P),\ + (__mmask8) -1,\ + _MM_FROUND_CUR_DIRECTION);\ +}) + +#define _mm_mask_cmp_ss_mask( __M, __X, __Y, __P) __extension__ ({ \ +__builtin_ia32_cmpss_mask ((__v4sf)( __X),\ + (__v4sf)( __Y),( __P),\ + (__mmask8)( __M),\ + _MM_FROUND_CUR_DIRECTION);\ +}) + +#define _mm_cmp_round_sd_mask( __X, __Y, __P,__R) __extension__ ({ \ +__builtin_ia32_cmpsd_mask ((__v2df)( __X),\ + (__v2df)( __Y), __P,\ + (__mmask8) -1, __R);\ +}) + +#define _mm_mask_cmp_round_sd_mask( __M, __X, __Y, __P, __R) __extension__ ({ \ +__builtin_ia32_cmpsd_mask ((__v2df)( __X),\ + (__v2df)( __Y), __P,\ + (__mmask8)( __M), __R);\ +}) + +#define _mm_cmp_sd_mask( __X, __Y, __P) __extension__ ({ \ +__builtin_ia32_cmpsd_mask ((__v2df)( __X),\ + (__v2df)( __Y),( __P),\ + (__mmask8) -1,\ + _MM_FROUND_CUR_DIRECTION);\ +}) + +#define _mm_mask_cmp_sd_mask( __M, __X, __Y, __P) __extension__ ({ \ +__builtin_ia32_cmpsd_mask ((__v2df)( __X),\ + (__v2df)( __Y),( __P),\ + (__mmask8)( __M),\ + _MM_FROUND_CUR_DIRECTION);\ +}) + #undef __DEFAULT_FN_ATTRS #endif // __AVX512FINTRIN_H diff --git a/clang/test/CodeGen/avx512f-builtins.c b/clang/test/CodeGen/avx512f-builtins.c index c73aa95b6d23..1b608085ac95 100644 --- a/clang/test/CodeGen/avx512f-builtins.c +++ b/clang/test/CodeGen/avx512f-builtins.c @@ -5285,3 +5285,51 @@ __m512i test_mm512_maskz_compress_epi32(__mmask16 __U, __m512i __A) { // CHECK: @llvm.x86.avx512.mask.compress.d.512 return _mm512_maskz_compress_epi32(__U, __A); } + +__mmask8 test_mm_cmp_round_ss_mask(__m128 __X, __m128 __Y) { + // CHECK-LABEL: @test_mm_cmp_round_ss_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_cmp_round_ss_mask(__X, __Y, 5, _MM_FROUND_CUR_DIRECTION); +} + +__mmask8 test_mm_mask_cmp_round_ss_mask(__mmask8 __M, __m128 __X, __m128 __Y) { + // CHECK-LABEL: @test_mm_mask_cmp_round_ss_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_mask_cmp_round_ss_mask(__M, __X, __Y, 5, _MM_FROUND_CUR_DIRECTION); +} + +__mmask8 test_mm_cmp_ss_mask(__m128 __X, __m128 __Y) { + // CHECK-LABEL: @test_mm_cmp_ss_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_cmp_ss_mask(__X, __Y, 5); +} + +__mmask8 test_mm_mask_cmp_ss_mask(__mmask8 __M, __m128 __X, __m128 __Y) { + // CHECK-LABEL: @test_mm_mask_cmp_ss_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_mask_cmp_ss_mask(__M, __X, __Y, 5); +} + +__mmask8 test_mm_cmp_round_sd_mask(__m128d __X, __m128d __Y) { + // CHECK-LABEL: @test_mm_cmp_round_sd_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_cmp_round_sd_mask(__X, __Y, 5, _MM_FROUND_CUR_DIRECTION); +} + +__mmask8 test_mm_mask_cmp_round_sd_mask(__mmask8 __M, __m128d __X, __m128d __Y) { + // CHECK-LABEL: @test_mm_mask_cmp_round_sd_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_mask_cmp_round_sd_mask(__M, __X, __Y, 5, _MM_FROUND_CUR_DIRECTION); +} + +__mmask8 test_mm_cmp_sd_mask(__m128d __X, __m128d __Y) { + // CHECK-LABEL: @test_mm_cmp_sd_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_cmp_sd_mask(__X, __Y, 5); +} + +__mmask8 test_mm_mask_cmp_sd_mask(__mmask8 __M, __m128d __X, __m128d __Y) { + // CHECK-LABEL: @test_mm_mask_cmp_sd_mask + // CHECK: @llvm.x86.avx512.mask.cmp + return _mm_mask_cmp_sd_mask(__M, __X, __Y, 5); +}