AVX512FP16: Add expander for cstorehf4.
authorliuhongt <hongtao.liu@intel.com>
Mon, 13 Jul 2020 08:04:05 +0000 (16:04 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 22 Sep 2021 04:56:31 +0000 (12:56 +0800)
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
gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512fp16-builtin-fpcompare-2.c [new file with mode: 0644]

index 0b17414..9bdd671 100644 (file)
   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 "cstore<mode>4"
   [(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 (file)
index 0000000..62115f1
--- /dev/null
@@ -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 (file)
index 0000000..150c351
--- /dev/null
@@ -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 } } */