]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AVX512FP16: Add expander for rint/nearbyinthf2.
authorliuhongt <hongtao.liu@intel.com>
Wed, 22 Sep 2021 07:03:36 +0000 (15:03 +0800)
committerliuhongt <hongtao.liu@intel.com>
Thu, 23 Sep 2021 09:05:01 +0000 (17:05 +0800)
gcc/ChangeLog:

* config/i386/i386.md (rinthf2): New expander.
(nearbyinthf2): New expander.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512fp16-builtin-round-1.c: Add new testcase.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/avx512fp16-builtin-round-1.c

index 60d877668d59f488501fdeed88fd5fbe74741bd7..4b13a59be8259b50705b513f987e2ace0d26085f 100644 (file)
    (set_attr "znver1_decode" "vector")
    (set_attr "mode" "XF")])
 
+(define_expand "rinthf2"
+  [(match_operand:HF 0 "register_operand")
+   (match_operand:HF 1 "nonimmediate_operand")]
+  "TARGET_AVX512FP16"
+{
+  emit_insn (gen_sse4_1_roundhf2 (operands[0],
+                                 operands[1],
+                                 GEN_INT (ROUND_MXCSR)));
+  DONE;
+})
+
 (define_expand "rint<mode>2"
   [(use (match_operand:MODEF 0 "register_operand"))
    (use (match_operand:MODEF 1 "nonimmediate_operand"))]
   "TARGET_USE_FANCY_MATH_387
    && !flag_trapping_math")
 
+(define_expand "nearbyinthf2"
+  [(match_operand:HF 0 "register_operand")
+   (match_operand:HF 1 "nonimmediate_operand")]
+  "TARGET_AVX512FP16"
+{
+  emit_insn (gen_sse4_1_roundhf2 (operands[0],
+                                 operands[1],
+                                 GEN_INT (ROUND_MXCSR | ROUND_NO_EXC)));
+  DONE;
+})
+
 (define_expand "nearbyint<mode>2"
   [(use (match_operand:MODEF 0 "register_operand"))
    (use (match_operand:MODEF 1 "nonimmediate_operand"))]
index 3cab1526967a6c23c62e18004e7acbda5da9fc28..a1c6636e3541c7d11a708192152edc178ebcddc7 100644 (file)
@@ -25,7 +25,21 @@ f4 (_Float16 x)
   return __builtin_roundevenf16 (x);
 }
 
+_Float16
+f5 (_Float16 x)
+{
+  return __builtin_rintf16 (x);
+}
+
+_Float16
+f6 (_Float16 x)
+{
+  return __builtin_nearbyintf16 (x);
+}
+
 /* { dg-final { scan-assembler-times "vrndscalesh\[ \\t\]+\\\$11\[^\n\r\]*xmm\[0-9\]" 1 } } */
 /* { dg-final { scan-assembler-times "vrndscalesh\[ \\t\]+\\\$10\[^\n\r\]*xmm\[0-9\]" 1 } } */
 /* { dg-final { scan-assembler-times "vrndscalesh\[ \\t\]+\\\$9\[^\n\r\]*xmm\[0-9\]" 1 } } */
 /* { dg-final { scan-assembler-times "vrndscalesh\[ \\t\]+\\\$8\[^\n\r\]*xmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vrndscalesh\[ \\t\]+\\\$4\[^\n\r\]*xmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vrndscalesh\[ \\t\]+\\\$12\[^\n\r\]*xmm\[0-9\]" 1 } } */