From 0eeb8c81e8cebdf5f719756d6ce5becc5d93b61f Mon Sep 17 00:00:00 2001 From: liuhongt Date: Mon, 13 Jul 2020 16:04:05 +0800 Subject: [PATCH] AVX512FP16: Add expander for cstorehf4. gcc/ChangeLog: * config/i386/i386.md (cstorehf3): New define_expand. gcc/testsuite/ChangeLog: * gcc.target/i386/avx512fp16-builtin-fpcompare-1.c: New test. * gcc.target/i386/avx512fp16-builtin-fpcompare-2.c: New test. --- gcc/config/i386/i386.md | 15 ++++++++ .../i386/avx512fp16-builtin-fpcompare-1.c | 40 ++++++++++++++++++++++ .../i386/avx512fp16-builtin-fpcompare-2.c | 29 ++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-2.c diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 0b17414..9bdd671 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1541,6 +1541,21 @@ DONE; }) +(define_expand "cstorehf4" + [(set (reg:CC FLAGS_REG) + (compare:CC (match_operand:HF 2 "cmp_fp_expander_operand") + (match_operand:HF 3 "cmp_fp_expander_operand"))) + (set (match_operand:QI 0 "register_operand") + (match_operator 1 "ix86_fp_comparison_operator" + [(reg:CC FLAGS_REG) + (const_int 0)]))] + "TARGET_AVX512FP16" +{ + ix86_expand_setcc (operands[0], GET_CODE (operands[1]), + operands[2], operands[3]); + DONE; +}) + (define_expand "cstore4" [(set (reg:CC FLAGS_REG) (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand") diff --git a/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-1.c b/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-1.c new file mode 100644 index 0000000..62115f1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-1.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -mavx512fp16" } */ + +int +f1 (_Float16 x, _Float16 y) +{ + return x > y; +} + +int +f2 (_Float16 x, _Float16 y) +{ + return x < y; +} + +/* { dg-final { scan-assembler-times "seta" 2 } } */ + +int +f3 (_Float16 x, _Float16 y) +{ + return x >= y; +} + +int +f4 (_Float16 x, _Float16 y) +{ + return x <= y; +} + +/* { dg-final { scan-assembler-times "setnb" 2 } } */ + +int +f5 (_Float16 x, _Float16 y) +{ + return __builtin_isunordered (x, y); +} + +/* { dg-final { scan-assembler-not "vcvtsh2s\[sd\]" } } */ +/* { dg-final { scan-assembler-times "xorl" 5 } } */ +/* { dg-final { scan-assembler-times "vcomish\[^\n\r\]*xmm\[0-9\]" 4 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-2.c b/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-2.c new file mode 100644 index 0000000..150c351 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mfpmath=sse -mavx512fp16" } */ + +int +foo (_Float16 y) +{ + return __builtin_isinf (y); +} + +int +foo2 (_Float16 y) +{ + return __builtin_isfinite (y); +} + +int +foo3 (_Float16 y) +{ + return __builtin_signbit(y); +} + +int +foo4 (_Float16 y) +{ + return __builtin_isnormal (y); +} + +/* { dg-final { scan-assembler-not "vcvtsh2s\[sd\]" } } */ +/* { dg-final { scan-assembler-times "vucomish\[^\n\r\]*xmm\[0-9\]" 4 } } */ -- 2.7.4