From dea061117ae1f09ace7a417ab57ba738699c8712 Mon Sep 17 00:00:00 2001 From: Andrew Senkevich Date: Mon, 23 Jan 2017 12:52:39 +0000 Subject: [PATCH] Add AVX512 k-mask intrinsics gcc/ * config/i386/avx512bwintrin.h: Add k-mask test, kortest intrinsics. * config/i386/avx512dqintrin.h: Ditto. * config/i386/avx512fintrin.h: Ditto. * gcc/config/i386/i386.c: Handle new builtins. * config/i386/i386-builtin.def: Add new builtins. * config/i386/sse.md (ktest, kortest): New. (UNSPEC_KORTEST, UNSPEC_KTEST): New. gcc/testsuite/ * gcc.target/i386/avx512bw-ktestd-1.c: New test. * gcc.target/i386/avx512bw-ktestq-1.c: Ditto. * gcc.target/i386/avx512dq-ktestb-1.c: Ditto. * gcc.target/i386/avx512f-ktestw-1.c: Ditto. * gcc.target/i386/avx512bw-kortestd-1.c: Ditto. * gcc.target/i386/avx512bw-kortestq-1.c: Ditto. * gcc.target/i386/avx512dq-kortestb-1.c: Ditto. * gcc.target/i386/avx512f-kortestw-1.c: Ditto. * gcc.target/i386/avx512bw-ktestd-2.c: Ditt * gcc.target/i386/avx512bw-ktestq-2.c: Ditto. * gcc.target/i386/avx512dq-ktestb-2.c: Ditto. * gcc.target/i386/avx512f-ktestw-2.c: Ditto. * gcc.target/i386/avx512bw-kortestd-2.c: Ditto. * gcc.target/i386/avx512bw-kortestq-2.c: Ditto. * gcc.target/i386/avx512dq-kortestb-2.c: Ditto. * gcc.target/i386/avx512f-kortestw-2.c: Ditto. From-SVN: r244801 --- gcc/ChangeLog | 14 ++- gcc/config/i386/avx512bwintrin.h | 88 +++++++++++++++++++ gcc/config/i386/avx512dqintrin.h | 44 ++++++++++ gcc/config/i386/avx512fintrin.h | 46 ++++++++++ gcc/config/i386/i386-builtin.def | 19 +++- gcc/config/i386/i386.c | 88 ++++++++++++++++++- gcc/config/i386/sse.md | 42 +++++---- gcc/testsuite/ChangeLog | 19 ++++ .../gcc.target/i386/avx512bw-kortestd-1.c | 16 ++++ .../gcc.target/i386/avx512bw-kortestd-2.c | 20 +++++ .../gcc.target/i386/avx512bw-kortestq-1.c | 16 ++++ .../gcc.target/i386/avx512bw-kortestq-2.c | 20 +++++ .../gcc.target/i386/avx512bw-ktestd-1.c | 16 ++++ .../gcc.target/i386/avx512bw-ktestd-2.c | 20 +++++ .../gcc.target/i386/avx512bw-ktestq-1.c | 16 ++++ .../gcc.target/i386/avx512bw-ktestq-2.c | 20 +++++ .../gcc.target/i386/avx512dq-kortestb-1.c | 16 ++++ .../gcc.target/i386/avx512dq-kortestb-2.c | 20 +++++ .../gcc.target/i386/avx512dq-ktestb-1.c | 16 ++++ .../gcc.target/i386/avx512dq-ktestb-2.c | 20 +++++ .../gcc.target/i386/avx512f-kortestw-1.c | 7 +- .../gcc.target/i386/avx512f-kortestw-2.c | 9 ++ .../gcc.target/i386/avx512f-ktestw-1.c | 16 ++++ .../gcc.target/i386/avx512f-ktestw-2.c | 20 +++++ 24 files changed, 599 insertions(+), 29 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-kortestd-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-kortestd-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-kortestq-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-kortestq-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-ktestd-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-ktestd-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-ktestq-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-ktestq-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512dq-kortestb-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512dq-kortestb-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512dq-ktestb-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512dq-ktestb-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-ktestw-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-ktestw-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5ab065fbcc7..b524d4ac17c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-01-23 Andrew Senkevich + + * config/i386/avx512bwintrin.h: Add k-mask test, kortest intrinsics. + * config/i386/avx512dqintrin.h: Ditto. + * config/i386/avx512fintrin.h: Ditto. + * gcc/config/i386/i386.c: Handle new builtins. + * config/i386/i386-builtin.def: Add new builtins. + * config/i386/sse.md (ktest, kortest): New. + (UNSPEC_KORTEST, UNSPEC_KTEST): New. + 2017-01-23 Jakub Jelinek Martin Liska @@ -41,7 +51,7 @@ now. Remove trailing slash. 2017-01-22 Gerald Pfeifer - + * README.Portability: Remove note on an Irix compatibility issue. 2017-01-22 Dimitry Andric @@ -49,7 +59,7 @@ * gcov.c (INCLUDE_ALGORITHM): Define. (INCLUDE_VECTOR): Define. No longer include and directly. - + 2017-01-21 Gerald Pfeifer * doc/extend.texi (Thread-Local): Change www.akkadia.org reference diff --git a/gcc/config/i386/avx512bwintrin.h b/gcc/config/i386/avx512bwintrin.h index e41428a2ec0..d05eed2cb95 100644 --- a/gcc/config/i386/avx512bwintrin.h +++ b/gcc/config/i386/avx512bwintrin.h @@ -40,6 +40,94 @@ typedef char __v64qi __attribute__ ((__vector_size__ (64))); typedef unsigned long long __mmask64; +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktest_mask32_u8 (__mmask32 __A, __mmask32 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_ktestcsi (__A, __B); + return (unsigned char) __builtin_ia32_ktestzsi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktest_mask64_u8 (__mmask64 __A, __mmask64 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_ktestcdi (__A, __B); + return (unsigned char) __builtin_ia32_ktestzdi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestz_mask32_u8 (__mmask32 __A, __mmask32 __B) +{ + return (unsigned char) __builtin_ia32_ktestzsi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestz_mask64_u8 (__mmask64 __A, __mmask64 __B) +{ + return (unsigned char) __builtin_ia32_ktestzdi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestc_mask32_u8 (__mmask32 __A, __mmask32 __B) +{ + return (unsigned char) __builtin_ia32_ktestcsi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestc_mask64_u8 (__mmask64 __A, __mmask64 __B) +{ + return (unsigned char) __builtin_ia32_ktestcdi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortest_mask32_u8 (__mmask32 __A, __mmask32 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_kortestcsi (__A, __B); + return (unsigned char) __builtin_ia32_kortestzsi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortest_mask64_u8 (__mmask64 __A, __mmask64 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_kortestcdi (__A, __B); + return (unsigned char) __builtin_ia32_kortestzdi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestz_mask32_u8 (__mmask32 __A, __mmask32 __B) +{ + return (unsigned char) __builtin_ia32_kortestzsi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestz_mask64_u8 (__mmask64 __A, __mmask64 __B) +{ + return (unsigned char) __builtin_ia32_kortestzdi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestc_mask32_u8 (__mmask32 __A, __mmask32 __B) +{ + return (unsigned char) __builtin_ia32_kortestcsi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestc_mask64_u8 (__mmask64 __A, __mmask64 __B) +{ + return (unsigned char) __builtin_ia32_kortestcdi (__A, __B); +} + extern __inline __mmask32 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _kadd_mask32 (__mmask32 __A, __mmask32 __B) diff --git a/gcc/config/i386/avx512dqintrin.h b/gcc/config/i386/avx512dqintrin.h index bcb4a321256..670e41e0b94 100644 --- a/gcc/config/i386/avx512dqintrin.h +++ b/gcc/config/i386/avx512dqintrin.h @@ -34,6 +34,50 @@ #define __DISABLE_AVX512DQ__ #endif /* __AVX512DQ__ */ +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktest_mask8_u8 (__mmask8 __A, __mmask8 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_ktestcqi (__A, __B); + return (unsigned char) __builtin_ia32_ktestzqi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestz_mask8_u8 (__mmask8 __A, __mmask8 __B) +{ + return (unsigned char) __builtin_ia32_ktestzqi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestc_mask8_u8 (__mmask8 __A, __mmask8 __B) +{ + return (unsigned char) __builtin_ia32_ktestcqi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortest_mask8_u8 (__mmask8 __A, __mmask8 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_kortestcqi (__A, __B); + return (unsigned char) __builtin_ia32_kortestzqi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestz_mask8_u8 (__mmask8 __A, __mmask8 __B) +{ + return (unsigned char) __builtin_ia32_kortestzqi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestc_mask8_u8 (__mmask8 __A, __mmask8 __B) +{ + return (unsigned char) __builtin_ia32_kortestcqi (__A, __B); +} + extern __inline __mmask8 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _kadd_mask8 (__mmask8 __A, __mmask8 __B) diff --git a/gcc/config/i386/avx512fintrin.h b/gcc/config/i386/avx512fintrin.h index 810ac23e0b5..6c11453287a 100644 --- a/gcc/config/i386/avx512fintrin.h +++ b/gcc/config/i386/avx512fintrin.h @@ -10006,6 +10006,52 @@ _mm512_maskz_expandloadu_epi32 (__mmask16 __U, void const *__P) #define _kxnor_mask16 _mm512_kxnor #define _kxor_mask16 _mm512_kxor +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktest_mask16_u8 (__mmask16 __A, __mmask16 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_ktestchi (__A, __B); + return (unsigned char) __builtin_ia32_ktestzhi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestz_mask16_u8 (__mmask16 __A, __mmask16 __B) +{ + return (unsigned char) __builtin_ia32_ktestzhi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_ktestc_mask16_u8 (__mmask16 __A, __mmask16 __B) +{ + return (unsigned char) __builtin_ia32_ktestchi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortest_mask16_u8 (__mmask16 __A, __mmask16 __B, unsigned char *__CF) +{ + *__CF = (unsigned char) __builtin_ia32_kortestchi (__A, __B); + return (unsigned char) __builtin_ia32_kortestzhi (__A, __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestz_mask16_u8 (__mmask16 __A, __mmask16 __B) +{ + return (unsigned char) __builtin_ia32_kortestzhi ((__mmask16) __A, + (__mmask16) __B); +} + +extern __inline unsigned char +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_kortestc_mask16_u8 (__mmask16 __A, __mmask16 __B) +{ + return (unsigned char) __builtin_ia32_kortestchi ((__mmask16) __A, + (__mmask16) __B); +} + extern __inline __mmask16 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _kadd_mask16 (__mmask16 __A, __mmask16 __B) diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def index 08ce2c98fcb..137aa3e1066 100644 --- a/gcc/config/i386/i386-builtin.def +++ b/gcc/config/i386/i386-builtin.def @@ -1464,8 +1464,23 @@ BDESC (OPTION_MASK_ISA_AVX512DQ, CODE_FOR_kiorqi, "__builtin_ia32_korqi", IX86_B BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kiorhi, "__builtin_ia32_korhi", IX86_BUILTIN_KOR16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_kiorsi, "__builtin_ia32_korsi", IX86_BUILTIN_KOR32, UNKNOWN, (int) USI_FTYPE_USI_USI) BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_kiordi, "__builtin_ia32_kordi", IX86_BUILTIN_KOR64, UNKNOWN, (int) UDI_FTYPE_UDI_UDI) -BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kortestchi, "__builtin_ia32_kortestchi", IX86_BUILTIN_KORTESTC16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) -BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kortestzhi, "__builtin_ia32_kortestzhi", IX86_BUILTIN_KORTESTZ16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) +BDESC (OPTION_MASK_ISA_AVX512DQ, CODE_FOR_ktestqi, "__builtin_ia32_ktestcqi", IX86_BUILTIN_KTESTC8, UNKNOWN, (int) UQI_FTYPE_UQI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ, CODE_FOR_ktestqi, "__builtin_ia32_ktestzqi", IX86_BUILTIN_KTESTZ8, UNKNOWN, (int) UQI_FTYPE_UQI_UQI) +BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_ktesthi, "__builtin_ia32_ktestchi", IX86_BUILTIN_KTESTC16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) +BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_ktesthi, "__builtin_ia32_ktestzhi", IX86_BUILTIN_KTESTZ16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_ktestsi, "__builtin_ia32_ktestcsi", IX86_BUILTIN_KTESTC32, UNKNOWN, (int) USI_FTYPE_USI_USI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_ktestsi, "__builtin_ia32_ktestzsi", IX86_BUILTIN_KTESTZ32, UNKNOWN, (int) USI_FTYPE_USI_USI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_ktestdi, "__builtin_ia32_ktestcdi", IX86_BUILTIN_KTESTC64, UNKNOWN, (int) UDI_FTYPE_UDI_UDI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_ktestdi, "__builtin_ia32_ktestzdi", IX86_BUILTIN_KTESTZ64, UNKNOWN, (int) UDI_FTYPE_UDI_UDI) +BDESC (OPTION_MASK_ISA_AVX512DQ, CODE_FOR_kortestqi, "__builtin_ia32_kortestcqi", IX86_BUILTIN_KORTESTC8, UNKNOWN, (int) UQI_FTYPE_UQI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ, CODE_FOR_kortestqi, "__builtin_ia32_kortestzqi", IX86_BUILTIN_KORTESTZ8, UNKNOWN, (int) UQI_FTYPE_UQI_UQI) +BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kortesthi, "__builtin_ia32_kortestchi", IX86_BUILTIN_KORTESTC16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) +BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kortesthi, "__builtin_ia32_kortestzhi", IX86_BUILTIN_KORTESTZ16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_kortestsi, "__builtin_ia32_kortestcsi", IX86_BUILTIN_KORTESTC32, UNKNOWN, (int) USI_FTYPE_USI_USI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_kortestsi, "__builtin_ia32_kortestzsi", IX86_BUILTIN_KORTESTZ32, UNKNOWN, (int) USI_FTYPE_USI_USI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_kortestdi, "__builtin_ia32_kortestcdi", IX86_BUILTIN_KORTESTC64, UNKNOWN, (int) UDI_FTYPE_UDI_UDI) +BDESC (OPTION_MASK_ISA_AVX512BW, CODE_FOR_kortestdi, "__builtin_ia32_kortestzdi", IX86_BUILTIN_KORTESTZ64, UNKNOWN, (int) UDI_FTYPE_UDI_UDI) + BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kunpckhi, "__builtin_ia32_kunpckhi", IX86_BUILTIN_KUNPCKBW, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) BDESC (OPTION_MASK_ISA_AVX512DQ, CODE_FOR_kxnorqi, "__builtin_ia32_kxnorqi", IX86_BUILTIN_KXNOR8, UNKNOWN, (int) UQI_FTYPE_UQI_UQI) BDESC (OPTION_MASK_ISA_AVX512F, CODE_FOR_kxnorhi, "__builtin_ia32_kxnorhi", IX86_BUILTIN_KXNOR16, UNKNOWN, (int) UHI_FTYPE_UHI_UHI) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 46d1c44d8fc..65b32e6da56 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -37642,16 +37642,100 @@ rdseed_step: emit_insn (gen_pop (gen_rtx_REG (word_mode, FLAGS_REG))); return 0; + case IX86_BUILTIN_KTESTC8: + icode = CODE_FOR_ktestqi; + mode0 = QImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KTESTZ8: + icode = CODE_FOR_ktestqi; + mode0 = QImode; + mode1 = CCZmode; + goto kortest; + + case IX86_BUILTIN_KTESTC16: + icode = CODE_FOR_ktesthi; + mode0 = HImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KTESTZ16: + icode = CODE_FOR_ktesthi; + mode0 = HImode; + mode1 = CCZmode; + goto kortest; + + case IX86_BUILTIN_KTESTC32: + icode = CODE_FOR_ktestsi; + mode0 = SImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KTESTZ32: + icode = CODE_FOR_ktestsi; + mode0 = SImode; + mode1 = CCZmode; + goto kortest; + + case IX86_BUILTIN_KTESTC64: + icode = CODE_FOR_ktestdi; + mode0 = DImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KTESTZ64: + icode = CODE_FOR_ktestdi; + mode0 = DImode; + mode1 = CCZmode; + goto kortest; + + case IX86_BUILTIN_KORTESTC8: + icode = CODE_FOR_kortestqi; + mode0 = QImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KORTESTZ8: + icode = CODE_FOR_kortestqi; + mode0 = QImode; + mode1 = CCZmode; + goto kortest; + case IX86_BUILTIN_KORTESTC16: - icode = CODE_FOR_kortestchi; + icode = CODE_FOR_kortesthi; mode0 = HImode; mode1 = CCCmode; goto kortest; case IX86_BUILTIN_KORTESTZ16: - icode = CODE_FOR_kortestzhi; + icode = CODE_FOR_kortesthi; mode0 = HImode; mode1 = CCZmode; + goto kortest; + + case IX86_BUILTIN_KORTESTC32: + icode = CODE_FOR_kortestsi; + mode0 = SImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KORTESTZ32: + icode = CODE_FOR_kortestsi; + mode0 = SImode; + mode1 = CCZmode; + goto kortest; + + case IX86_BUILTIN_KORTESTC64: + icode = CODE_FOR_kortestdi; + mode0 = DImode; + mode1 = CCCmode; + goto kortest; + + case IX86_BUILTIN_KORTESTZ64: + icode = CODE_FOR_kortestdi; + mode0 = DImode; + mode1 = CCZmode; kortest: arg0 = CALL_EXPR_ARG (exp, 0); /* Mask reg src1. */ diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index bc504eb874a..0d074f851a2 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -108,6 +108,8 @@ ;; Mask operations UNSPEC_MASKOP + UNSPEC_KORTEST + UNSPEC_KTEST ;; For embed. rounding feature UNSPEC_EMBEDDED_ROUNDING @@ -1422,31 +1424,27 @@ (set_attr "prefix" "vex") (set_attr "mode" "")]) -;;There are kortrest[bdq] but no intrinsics for them. -;;We probably don't need to implement them. -(define_insn "kortestzhi" - [(set (reg:CCZ FLAGS_REG) - (compare:CCZ - (ior:HI - (match_operand:HI 0 "register_operand" "k") - (match_operand:HI 1 "register_operand" "k")) - (const_int 0)))] - "TARGET_AVX512F && ix86_match_ccmode (insn, CCZmode)" - "kortestw\t{%1, %0|%0, %1}" - [(set_attr "mode" "HI") +(define_insn "ktest" + [(set (reg:CC FLAGS_REG) + (unspec:CC + [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "k") + (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")] + UNSPEC_KTEST))] + "TARGET_AVX512F" + "ktest\t{%1, %0|%0, %1}" + [(set_attr "mode" "") (set_attr "type" "msklog") (set_attr "prefix" "vex")]) -(define_insn "kortestchi" - [(set (reg:CCC FLAGS_REG) - (compare:CCC - (ior:HI - (match_operand:HI 0 "register_operand" "k") - (match_operand:HI 1 "register_operand" "k")) - (const_int -1)))] - "TARGET_AVX512F && ix86_match_ccmode (insn, CCCmode)" - "kortestw\t{%1, %0|%0, %1}" - [(set_attr "mode" "HI") +(define_insn "kortest" + [(set (reg:CC FLAGS_REG) + (unspec:CC + [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "k") + (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")] + UNSPEC_KORTEST))] + "TARGET_AVX512F" + "kortest\t{%1, %0|%0, %1}" + [(set_attr "mode" "") (set_attr "type" "msklog") (set_attr "prefix" "vex")]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cafb05882c2..d6db7601c8f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,22 @@ +2017-01-23 Andrew Senkevich + + * gcc.target/i386/avx512bw-ktestd-1.c: New test. + * gcc.target/i386/avx512bw-ktestq-1.c: Ditto. + * gcc.target/i386/avx512dq-ktestb-1.c: Ditto. + * gcc.target/i386/avx512f-ktestw-1.c: Ditto. + * gcc.target/i386/avx512bw-kortestd-1.c: Ditto. + * gcc.target/i386/avx512bw-kortestq-1.c: Ditto. + * gcc.target/i386/avx512dq-kortestb-1.c: Ditto. + * gcc.target/i386/avx512f-kortestw-1.c: Ditto. + * gcc.target/i386/avx512bw-ktestd-2.c: Ditt + * gcc.target/i386/avx512bw-ktestq-2.c: Ditto. + * gcc.target/i386/avx512dq-ktestb-2.c: Ditto. + * gcc.target/i386/avx512f-ktestw-2.c: Ditto. + * gcc.target/i386/avx512bw-kortestd-2.c: Ditto. + * gcc.target/i386/avx512bw-kortestq-2.c: Ditto. + * gcc.target/i386/avx512dq-kortestb-2.c: Ditto. + * gcc.target/i386/avx512f-kortestw-2.c: Ditto. + 2017-01-23 Richard Biener Nick Clifton diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-kortestd-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-kortestd-1.c new file mode 100644 index 00000000000..9d6235c72ee --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-kortestd-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512bw" } */ +/* { dg-final { scan-assembler-times "kortestd\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512bw_test () { + volatile __mmask32 k1; + __mmask32 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _kortestc_mask32_u8(k1, k2); + r = _kortestz_mask32_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-kortestd-2.c b/gcc/testsuite/gcc.target/i386/avx512bw-kortestd-2.c new file mode 100644 index 00000000000..741bbbfca6a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-kortestd-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" + +void +avx512bw_test () +{ + volatile __mmask32 k1, k2; + unsigned char r1, r2; + + __asm__( "kmovd %1, %0" : "=k" (k1) : "r" (0) ); + __asm__( "kmovd %1, %0" : "=k" (k2) : "r" (-1) ); + + r1 = _kortest_mask32_u8(k1, k2, &r2); + + if ( r1 != 0 || r2 != 1 ) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-kortestq-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-kortestq-1.c new file mode 100644 index 00000000000..7f2761873ea --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-kortestq-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512bw" } */ +/* { dg-final { scan-assembler-times "kortestq\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512bw_test () { + volatile __mmask64 k1; + __mmask64 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _kortestc_mask64_u8(k1, k2); + r = _kortestz_mask64_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-kortestq-2.c b/gcc/testsuite/gcc.target/i386/avx512bw-kortestq-2.c new file mode 100644 index 00000000000..9efaac22ec2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-kortestq-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" + +void +avx512bw_test () +{ + __mmask64 k1, k2; + unsigned char r1, r2; + + k1 = _cvtu64_mask64(0); + k2 = _cvtu64_mask64(-1); + + r1 = _kortest_mask64_u8(k1, k2, &r2); + + if (r1 != 0 || r2 != 1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-ktestd-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-ktestd-1.c new file mode 100644 index 00000000000..56d3c4aad0b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-ktestd-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512bw" } */ +/* { dg-final { scan-assembler-times "ktestd\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512bw_test () { + volatile __mmask32 k1; + __mmask32 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _ktestc_mask32_u8(k1, k2); + r = _ktestz_mask32_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-ktestd-2.c b/gcc/testsuite/gcc.target/i386/avx512bw-ktestd-2.c new file mode 100644 index 00000000000..d931f0a2e08 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-ktestd-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" + +void +avx512bw_test () +{ + volatile __mmask32 k1, k2; + unsigned char r1, r2; + + __asm__( "kmovd %1, %0" : "=k" (k1) : "r" (0) ); + __asm__( "kmovd %1, %0" : "=k" (k2) : "r" (-1) ); + + r1 = _ktest_mask32_u8(k1, k2, &r2); + + if (r1 != 1 || r2 != 0) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-ktestq-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-ktestq-1.c new file mode 100644 index 00000000000..3d911326506 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-ktestq-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512bw" } */ +/* { dg-final { scan-assembler-times "ktestq\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512bw_test () { + volatile __mmask64 k1; + __mmask64 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _ktestc_mask64_u8(k1, k2); + r = _ktestz_mask64_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-ktestq-2.c b/gcc/testsuite/gcc.target/i386/avx512bw-ktestq-2.c new file mode 100644 index 00000000000..518d829837b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-ktestq-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" + +void +avx512bw_test () +{ + __mmask64 k1, k2; + unsigned char r1, r2; + + k1 = _cvtu64_mask64(0); + k2 = _cvtu64_mask64(-1); + + r1 = _ktest_mask64_u8(k1, k2, &r2); + + if (r1 != 1 || r2 != 0) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512dq-kortestb-1.c b/gcc/testsuite/gcc.target/i386/avx512dq-kortestb-1.c new file mode 100644 index 00000000000..b743d604fa1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512dq-kortestb-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512dq" } */ +/* { dg-final { scan-assembler-times "kortestb\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512dq_test () { + volatile __mmask8 k1; + __mmask8 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _kortestc_mask8_u8(k1, k2); + r = _kortestz_mask8_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512dq-kortestb-2.c b/gcc/testsuite/gcc.target/i386/avx512dq-kortestb-2.c new file mode 100644 index 00000000000..b71346abd2e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512dq-kortestb-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512dq" } */ +/* { dg-require-effective-target avx512dq } */ + +#include "avx512dq-check.h" + +void +avx512dq_test () +{ + volatile __mmask8 k1, k2; + unsigned char r1, r2; + + __asm__( "kmovb %1, %0" : "=k" (k1) : "r" (0) ); + __asm__( "kmovb %1, %0" : "=k" (k2) : "r" (-1) ); + + r1 = _kortest_mask8_u8(k1, k2, &r2); + + if (r1 != 0 || r2 != 1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512dq-ktestb-1.c b/gcc/testsuite/gcc.target/i386/avx512dq-ktestb-1.c new file mode 100644 index 00000000000..4e13fd0539c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512dq-ktestb-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512dq" } */ +/* { dg-final { scan-assembler-times "ktestb\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512dq_test () { + volatile __mmask8 k1; + __mmask8 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _ktestc_mask8_u8(k1, k2); + r = _ktestz_mask8_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512dq-ktestb-2.c b/gcc/testsuite/gcc.target/i386/avx512dq-ktestb-2.c new file mode 100644 index 00000000000..0c6e7c0ac6b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512dq-ktestb-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512dq" } */ +/* { dg-require-effective-target avx512dq } */ + +#include "avx512dq-check.h" + +void +avx512dq_test () +{ + volatile __mmask8 k1, k2; + unsigned char r1, r2; + + __asm__( "kmovb %1, %0" : "=k" (k1) : "r" (0) ); + __asm__( "kmovb %1, %0" : "=k" (k2) : "r" (-1) ); + + r1 = _ktest_mask8_u8(k1, k2, &r2); + + if (r1 != 1 || r2 != 0) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-kortestw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-kortestw-1.c index af6f5f19f69..7084ada8c61 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-kortestw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-kortestw-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O0 -mavx512f" } */ -/* { dg-final { scan-assembler-times "kortestw\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 4 } } */ +/* { dg-final { scan-assembler-times "kortestw\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 6 } } */ #include @@ -19,4 +19,9 @@ avx512f_test () { r = _mm512_kortestc (k3, k4); r = _mm512_kortestz (k3, k4); + + volatile unsigned char r1 __attribute__((unused)); + + r1 = _kortestc_mask16_u8(k1, k2); + r1 = _kortestz_mask16_u8(k1, k2); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-kortestw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-kortestw-2.c index 4b9cadcc2d1..d2a56e4893c 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-kortestw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-kortestw-2.c @@ -9,6 +9,8 @@ avx512f_test () { volatile __mmask16 k1; __mmask16 k2; volatile short r = 0; + volatile unsigned char r1 = 0; + unsigned char r2; /* Test kortestc. */ __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) ); @@ -50,4 +52,11 @@ avx512f_test () { r += _mm512_kortestz (k1, k2); if (!r) abort (); + + __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) ); + __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (-1) ); + + r1 = _kortest_mask16_u8 (k1, k2, &r2); + if (r1 != 0 || r2 != 1) + abort (); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-ktestw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-ktestw-1.c new file mode 100644 index 00000000000..f6151d1671d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-ktestw-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx512f" } */ +/* { dg-final { scan-assembler-times "ktestw\[ \\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 2 } } */ + +#include + +void +avx512f_test () { + volatile __mmask16 k1; + __mmask16 k2; + + volatile unsigned char r __attribute__((unused)); + + r = _ktestc_mask16_u8(k1, k2); + r = _ktestz_mask16_u8(k1, k2); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-ktestw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-ktestw-2.c new file mode 100644 index 00000000000..6602c7a1574 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-ktestw-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#include "avx512f-check.h" + +void +avx512f_test () +{ + volatile __mmask16 k1, k2; + unsigned char r1, r2; + + __asm__( "kmovw %1, %0" : "=k" (k1) : "r" (0) ); + __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (-1) ); + + r1 = _ktest_mask16_u8(k1, k2, &r2); + + if (r1 != 1 || r2 != 0) + abort (); +} -- 2.30.2