public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pan Li <panli@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4610] RISC-V: Add test for FP llround auto vectorization
Date: Fri, 13 Oct 2023 06:21:45 +0000 (GMT)	[thread overview]
Message-ID: <20231013062145.2FE633858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:6b580560a0e393e3b65567263e2cf5477d670592

commit r14-4610-g6b580560a0e393e3b65567263e2cf5477d670592
Author: Pan Li <pan2.li@intel.com>
Date:   Fri Oct 13 14:13:26 2023 +0800

    RISC-V: Add test for FP llround auto vectorization
    
    The below FP API are supported already by sharing the same standard
    name, as well as the machine mode.
    
    long long llround (double);
    
    This patch would like to add the test cases for ensuring the correctness.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/rvv/autovec/unop/math-llround-0.c: New test.
            * gcc.target/riscv/rvv/autovec/unop/math-llround-run-0.c: New test.
            * gcc.target/riscv/rvv/autovec/vls/math-llround-0.c: New test.
    
    Signed-off-by: Pan Li <pan2.li@intel.com>

Diff:
---
 .../riscv/rvv/autovec/unop/math-llround-0.c        | 20 +++++++
 .../riscv/rvv/autovec/unop/math-llround-run-0.c    | 64 ++++++++++++++++++++++
 .../riscv/rvv/autovec/vls/math-llround-0.c         | 30 ++++++++++
 3 files changed, 114 insertions(+)

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llround-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llround-0.c
new file mode 100644
index 00000000000..4f8b4553a91
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llround-0.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include <stdint-gcc.h>
+#include "test-math.h"
+
+/*
+** test_double_int64_t___builtin_llround:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+4
+**   ...
+**   vsetvli\s+[atx][0-9]+,\s*zero,\s*e64,\s*m1,\s*ta,\s*ma
+**   vfcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (double, int64_t, __builtin_llround)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llround-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llround-run-0.c
new file mode 100644
index 00000000000..c5b60847cc7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llround-run-0.c
@@ -0,0 +1,64 @@
+/* { dg-do run { target { riscv_v && rv64 } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */
+
+#include <stdint-gcc.h>
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+double in[ARRAY_SIZE];
+int64_t out[ARRAY_SIZE];
+int64_t ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (double, int64_t, __builtin_llround)
+TEST_ASSERT (int64_t)
+
+TEST_INIT_CVT (double, 1.2, int64_t, __builtin_llround (1.2), 1)
+TEST_INIT_CVT (double, -1.2, int64_t, __builtin_llround (-1.2), 2)
+TEST_INIT_CVT (double, 0.5, int64_t, __builtin_llround (0.5), 3)
+TEST_INIT_CVT (double, -0.5, int64_t, __builtin_llround (-0.5), 4)
+TEST_INIT_CVT (double, 0.1, int64_t, __builtin_llround (0.1), 5)
+TEST_INIT_CVT (double, -0.1, int64_t, __builtin_llround (-0.1), 6)
+TEST_INIT_CVT (double, 3.0, int64_t, __builtin_llround (3.0), 7)
+TEST_INIT_CVT (double, -3.0, int64_t, __builtin_llround (-3.0), 8)
+TEST_INIT_CVT (double, 4503599627370495.5, int64_t, __builtin_llround (4503599627370495.5), 9)
+TEST_INIT_CVT (double, 4503599627370497.0, int64_t, __builtin_llround (4503599627370497.0), 10)
+TEST_INIT_CVT (double, -4503599627370495.5, int64_t, __builtin_llround (-4503599627370495.5), 11)
+TEST_INIT_CVT (double, -4503599627370496.0, int64_t, __builtin_llround (-4503599627370496.0), 12)
+TEST_INIT_CVT (double, 0.0, int64_t, __builtin_llround (-0.0), 13)
+TEST_INIT_CVT (double, -0.0, int64_t, __builtin_llround (-0.0), 14)
+TEST_INIT_CVT (double, 9223372036854774784.0, int64_t, __builtin_llround (9223372036854774784.0), 15)
+TEST_INIT_CVT (double, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 16)
+TEST_INIT_CVT (double, -9223372036854775808.0, int64_t, __builtin_llround (-9223372036854775808.0), 17)
+TEST_INIT_CVT (double, -9223372036854777856.0, int64_t, 0x8000000000000000, 18)
+TEST_INIT_CVT (double, __builtin_inf (), int64_t, __builtin_llround (__builtin_inf ()), 19)
+TEST_INIT_CVT (double, -__builtin_inf (), int64_t, __builtin_llround (-__builtin_inf ()), 20)
+TEST_INIT_CVT (double, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 21)
+
+int
+main ()
+{
+  RUN_TEST_CVT (double, int64_t, 1, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 2, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 3, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 4, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 5, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 6, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 7, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 8, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 9, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 10, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 11, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 12, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 13, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 14, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 15, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 16, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 17, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 18, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 19, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 20, __builtin_llround, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int64_t, 21, __builtin_llround, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llround-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llround-0.c
new file mode 100644
index 00000000000..9bed7648b43
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llround-0.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (llround, 1, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 2, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 4, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 8, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 16, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 32, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 64, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 128, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 256, double, int64_t, __builtin_llround)
+DEF_OP_V_CVT (llround, 512, double, int64_t, __builtin_llround)
+
+/* { dg-final { scan-assembler-not {csrr} } } */
+/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "1024,1024" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4096,4096" "optimized" } } */
+/* { dg-final { scan-assembler-times {vfcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */

                 reply	other threads:[~2023-10-13  6:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231013062145.2FE633858D1E@sourceware.org \
    --to=panli@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).