From: Jakub Jelinek Date: Mon, 5 Sep 2016 19:45:21 +0000 (+0200) Subject: re PR target/77476 ([AVX-512] illegal kmovb instruction on KNL) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de9188e00495478f948a0b18650a9d90afd970f5;p=gcc.git re PR target/77476 ([AVX-512] illegal kmovb instruction on KNL) PR target/77476 * config/i386/i386.md (isa): Add x64_avx512bw. (*zero_extendsidi2): For alternative 11 use x64_avx512bw isa. (kmov_isa): New mode attr. (zero_extenddi2): Use isa for the last alternative. (*zero_extendsi2): Likewise. (*zero_extendqihi2): Use avx512dq isa for the last alternative. * gcc.target/i386/avx512f-pr77476.c: New test. * gcc.target/i386/avx512bw-pr77476.c: New test. * gcc.target/i386/avx512dq-pr77476.c: New test. From-SVN: r240000 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 536e0094dd4..4335b9d86ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2016-09-05 Jakub Jelinek + + PR target/77476 + * config/i386/i386.md (isa): Add x64_avx512bw. + (*zero_extendsidi2): For alternative 11 use x64_avx512bw isa. + (kmov_isa): New mode attr. + (zero_extenddi2): Use isa for the last alternative. + (*zero_extendsi2): Likewise. + (*zero_extendqihi2): Use avx512dq isa for the last alternative. + 2016-09-05 Gerald Pfeifer * doc/invoke.texi (SPU Options): nops -> NOPs. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 0deecb1b366..e3c9eadde85 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -799,7 +799,7 @@ sse2,sse2_noavx,sse3,sse4,sse4_noavx,avx,noavx, avx2,noavx2,bmi,bmi2,fma4,fma,avx512f,noavx512f, fma_avx512f,avx512bw,noavx512bw,avx512dq,noavx512dq, - avx512vl,noavx512vl,x64_avx512dq" + avx512vl,noavx512vl,x64_avx512dq,x64_avx512bw" (const_string "base")) (define_attr "enabled" "" @@ -812,6 +812,8 @@ (symbol_ref "TARGET_64BIT && TARGET_AVX") (eq_attr "isa" "x64_avx512dq") (symbol_ref "TARGET_64BIT && TARGET_AVX512DQ") + (eq_attr "isa" "x64_avx512bw") + (symbol_ref "TARGET_64BIT && TARGET_AVX512BW") (eq_attr "isa" "nox64") (symbol_ref "!TARGET_64BIT") (eq_attr "isa" "sse2") (symbol_ref "TARGET_SSE2") (eq_attr "isa" "sse2_noavx") @@ -3735,12 +3737,14 @@ [(set (attr "isa") (cond [(eq_attr "alternative" "0,1,2") (const_string "nox64") - (eq_attr "alternative" "3,7,11") + (eq_attr "alternative" "3,7") (const_string "x64") (eq_attr "alternative" "8") (const_string "x64_sse4") (eq_attr "alternative" "10") (const_string "sse2") + (eq_attr "alternative" "11") + (const_string "x64_avx512bw") ] (const_string "*"))) (set (attr "type") @@ -3804,6 +3808,9 @@ (set (match_dup 4) (const_int 0))] "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);") +(define_mode_attr kmov_isa + [(QI "avx512dq") (HI "avx512f") (SI "avx512bw") (DI "avx512bw")]) + (define_insn "zero_extenddi2" [(set (match_operand:DI 0 "register_operand" "=r,*r") (zero_extend:DI @@ -3812,7 +3819,8 @@ "@ movz{l|x}\t{%1, %k0|%k0, %1} kmov\t{%1, %k0|%k0, %1}" - [(set_attr "type" "imovx,mskmov") + [(set_attr "isa" "*,") + (set_attr "type" "imovx,mskmov") (set_attr "mode" "SI")]) (define_expand "zero_extendsi2" @@ -3863,7 +3871,8 @@ "@ movz{l|x}\t{%1, %0|%0, %1} kmov\t{%1, %0|%0, %1}" - [(set_attr "type" "imovx,mskmov") + [(set_attr "isa" "*,") + (set_attr "type" "imovx,mskmov") (set_attr "mode" "SI,")]) (define_expand "zero_extendqihi2" @@ -3914,6 +3923,7 @@ movz{bl|x}\t{%1, %k0|%k0, %1} kmovb\t{%1, %k0|%k0, %1}" [(set_attr "type" "imovx,mskmov") + (set_attr "isa" "*,avx512dq") (set_attr "mode" "SI,QI")]) (define_insn_and_split "*zext_doubleword_and" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7c951b6a56..c91ad0d3101 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2016-09-05 Jakub Jelinek + PR target/77476 + * gcc.target/i386/avx512f-pr77476.c: New test. + * gcc.target/i386/avx512bw-pr77476.c: New test. + * gcc.target/i386/avx512dq-pr77476.c: New test. + * lib/target-supports.exp (check_effective_target_vect_simd_clones): Update comment to mention also avx512f. diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr77476.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr77476.c new file mode 100644 index 00000000000..bae00e4ee51 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-pr77476.c @@ -0,0 +1,9 @@ +/* PR target/77476 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" +#define PR77476_TEST avx512bw_test + +#include "avx512f-pr77476.c" diff --git a/gcc/testsuite/gcc.target/i386/avx512dq-pr77476.c b/gcc/testsuite/gcc.target/i386/avx512dq-pr77476.c new file mode 100644 index 00000000000..77d024e053e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512dq-pr77476.c @@ -0,0 +1,9 @@ +/* PR target/77476 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512dq" } */ +/* { dg-require-effective-target avx512dq } */ + +#include "avx512dq-check.h" +#define PR77476_TEST avx512dq_test + +#include "avx512f-pr77476.c" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr77476.c b/gcc/testsuite/gcc.target/i386/avx512f-pr77476.c new file mode 100644 index 00000000000..f3bd509535a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr77476.c @@ -0,0 +1,76 @@ +/* PR target/77476 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#ifndef PR77476_TEST +#include "avx512f-check.h" +#define PR77476_TEST avx512f_test +#endif + +unsigned short s; +unsigned int i; +unsigned long long l; + +void +f1 (void) +{ + unsigned char a = 0xff; + asm volatile ("" : "+Yk" (a)); + s = a; +} + +void +f2 (void) +{ + unsigned char a = 0xff; + asm volatile ("" : "+Yk" (a)); + i = a; +} + +void +f3 (void) +{ + unsigned char a = 0xff; + asm volatile ("" : "+Yk" (a)); + l = a; +} + +void +f4 (void) +{ + unsigned short a = 0xffff; + asm volatile ("" : "+Yk" (a)); + i = a; +} + +void +f5 (void) +{ + unsigned short a = 0xffff; + asm volatile ("" : "+Yk" (a)); + l = a; +} + +#ifdef __AVX512BW__ +void +f6 (void) +{ + unsigned int a = 0xffffffff; + asm volatile ("" : "+Yk" (a)); + l = a; +} +#endif + +static void +PR77476_TEST () +{ + f1 (); if (s != 0xff) __builtin_abort (); s = 0; + f2 (); if (i != 0xff) __builtin_abort (); i = 0; + f3 (); if (l != 0xff) __builtin_abort (); l = 0; + f4 (); if (i != 0xffff) __builtin_abort (); i = 0; + f5 (); if (l != 0xffff) __builtin_abort (); l = 0; +#ifdef __AVX512BW__ + f6 (); if (l != 0xffffffff) __builtin_abort (); l = 0; +#endif +}