public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@gmail.com>
To: pan2.li@intel.com
Cc: gcc-patches@gcc.gnu.org, juzhe.zhong@rivai.ai,
	jeffreyalaw@gmail.com,  rdapp.gcc@gmail.com
Subject: Re: [PATCH v1 2/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 3
Date: Sat, 17 Aug 2024 21:54:00 +0800	[thread overview]
Message-ID: <CA+yXCZCy8NDXESbuhNsKBbcLz_nwipr1VDCdA8sx7hvm+mHUgw@mail.gmail.com> (raw)
In-Reply-To: <20240817113641.73334-2-pan2.li@intel.com>

[-- Attachment #1: Type: text/plain, Size: 8594 bytes --]

LGTM

<pan2.li@intel.com> 於 2024年8月17日 週六 19:37 寫道:

> From: Pan Li <pan2.li@intel.com>
>
> This patch would like to add test cases for the unsigned scalar
> .SAT_TRUNC form 3.  Aka:
>
> Form 3:
>   #define DEF_SAT_U_TRUC_FMT_3(NT, WT)     \
>   NT __attribute__((noinline))             \
>   sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \
>   {                                        \
>     WT max = (WT)(NT)-1;                   \
>     return x <= max ? (NT)x : (NT) max;    \
>   }
>
> DEF_SAT_U_TRUC_FMT_3 (uint32_t, uint64_t)
>
> The below test is passed for this patch.
> * The rv64gcv regression test.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/riscv/sat_arith.h: Add test helper macros.
>         * gcc.target/riscv/sat_u_trunc-13.c: New test.
>         * gcc.target/riscv/sat_u_trunc-14.c: New test.
>         * gcc.target/riscv/sat_u_trunc-15.c: New test.
>         * gcc.target/riscv/sat_u_trunc-run-13.c: New test.
>         * gcc.target/riscv/sat_u_trunc-run-14.c: New test.
>         * gcc.target/riscv/sat_u_trunc-run-15.c: New test.
>
> Signed-off-by: Pan Li <pan2.li@intel.com>
> ---
>  gcc/testsuite/gcc.target/riscv/sat_arith.h    | 12 +++++++++++
>  .../gcc.target/riscv/sat_u_trunc-13.c         | 17 ++++++++++++++++
>  .../gcc.target/riscv/sat_u_trunc-14.c         | 20 +++++++++++++++++++
>  .../gcc.target/riscv/sat_u_trunc-15.c         | 19 ++++++++++++++++++
>  .../gcc.target/riscv/sat_u_trunc-run-13.c     | 16 +++++++++++++++
>  .../gcc.target/riscv/sat_u_trunc-run-14.c     | 16 +++++++++++++++
>  .../gcc.target/riscv/sat_u_trunc-run-15.c     | 16 +++++++++++++++
>  7 files changed, 116 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c
>
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h
> b/gcc/testsuite/gcc.target/riscv/sat_arith.h
> index 576a4926d1f..cf055410fd1 100644
> --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h
> +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h
> @@ -236,10 +236,22 @@ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \
>  }
>  #define DEF_SAT_U_TRUC_FMT_2_WRAP(NT, WT) DEF_SAT_U_TRUC_FMT_2(NT, WT)
>
> +#define DEF_SAT_U_TRUC_FMT_3(NT, WT)     \
> +NT __attribute__((noinline))             \
> +sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \
> +{                                        \
> +  WT max = (WT)(NT)-1;                   \
> +  return x <= max ? (NT)x : (NT) max;    \
> +}
> +#define DEF_SAT_U_TRUC_FMT_3_WRAP(NT, WT) DEF_SAT_U_TRUC_FMT_3(NT, WT)
> +
>  #define RUN_SAT_U_TRUC_FMT_1(NT, WT, x) sat_u_truc_##WT##_to_##NT##_fmt_1
> (x)
>  #define RUN_SAT_U_TRUC_FMT_1_WRAP(NT, WT, x) RUN_SAT_U_TRUC_FMT_1(NT, WT,
> x)
>
>  #define RUN_SAT_U_TRUC_FMT_2(NT, WT, x) sat_u_truc_##WT##_to_##NT##_fmt_2
> (x)
>  #define RUN_SAT_U_TRUC_FMT_2_WRAP(NT, WT, x) RUN_SAT_U_TRUC_FMT_2(NT, WT,
> x)
>
> +#define RUN_SAT_U_TRUC_FMT_3(NT, WT, x) sat_u_truc_##WT##_to_##NT##_fmt_3
> (x)
> +#define RUN_SAT_U_TRUC_FMT_3_WRAP(NT, WT, x) RUN_SAT_U_TRUC_FMT_3(NT, WT,
> x)
> +
>  #endif
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c
> b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c
> new file mode 100644
> index 00000000000..58910793a80
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c
> @@ -0,0 +1,17 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details
> -fno-schedule-insns -fno-schedule-insns2" } */
> +/* { dg-final { check-function-bodies "**" "" } } */
> +
> +#include "sat_arith.h"
> +
> +/*
> +** sat_u_truc_uint16_t_to_uint8_t_fmt_3:
> +** sltiu\s+[atx][0-9]+,\s*a0,\s*255
> +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1
> +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
> +** andi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*0xff
> +** ret
> +*/
> +DEF_SAT_U_TRUC_FMT_3(uint8_t, uint16_t)
> +
> +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c
> b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c
> new file mode 100644
> index 00000000000..236ea1d45f7
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c
> @@ -0,0 +1,20 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details
> -fno-schedule-insns -fno-schedule-insns2" } */
> +/* { dg-final { check-function-bodies "**" "" } } */
> +
> +#include "sat_arith.h"
> +
> +/*
> +** sat_u_truc_uint32_t_to_uint16_t_fmt_3:
> +** li\s+[atx][0-9]+,\s*65536
> +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1
> +** sltu\s+[atx][0-9]+,\s*a0,\s*[atx][0-9]+
> +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1
> +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
> +** slli\s+a0,\s*a0,\s*48
> +** srli\s+a0,\s*a0,\s*48
> +** ret
> +*/
> +DEF_SAT_U_TRUC_FMT_3(uint16_t, uint32_t)
> +
> +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c
> b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c
> new file mode 100644
> index 00000000000..33c3686c053
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c
> @@ -0,0 +1,19 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details
> -fno-schedule-insns -fno-schedule-insns2" } */
> +/* { dg-final { check-function-bodies "**" "" } } */
> +
> +#include "sat_arith.h"
> +
> +/*
> +** sat_u_truc_uint64_t_to_uint32_t_fmt_3:
> +** li\s+[atx][0-9]+,\s*-1
> +** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
> +** sltu\s+[atx][0-9]+,\s*a0,\s*[atx][0-9]+
> +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1
> +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
> +** sext.w\s+a0,\s*a0
> +** ret
> +*/
> +DEF_SAT_U_TRUC_FMT_3(uint32_t, uint64_t)
> +
> +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.c
> b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.c
> new file mode 100644
> index 00000000000..6322305c5ed
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.c
> @@ -0,0 +1,16 @@
> +/* { dg-do run { target { riscv_v } } } */
> +/* { dg-additional-options "-std=c99" } */
> +
> +#include "sat_arith.h"
> +#include "sat_arith_data.h"
> +
> +#define T1 uint8_t
> +#define T2 uint16_t
> +
> +DEF_SAT_U_TRUC_FMT_3_WRAP(T1, T2)
> +
> +#define DATA           TEST_UNARY_DATA_WRAP(T1, T2)
> +#define T              TEST_UNARY_STRUCT_DECL(T1, T2)
> +#define RUN_UNARY(x)   RUN_SAT_U_TRUC_FMT_3_WRAP(T1, T2, x)
> +
> +#include "scalar_sat_unary.h"
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c
> b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c
> new file mode 100644
> index 00000000000..a29e887aeeb
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c
> @@ -0,0 +1,16 @@
> +/* { dg-do run { target { riscv_v } } } */
> +/* { dg-additional-options "-std=c99" } */
> +
> +#include "sat_arith.h"
> +#include "sat_arith_data.h"
> +
> +#define T1 uint16_t
> +#define T2 uint32_t
> +
> +DEF_SAT_U_TRUC_FMT_3_WRAP(T1, T2)
> +
> +#define DATA           TEST_UNARY_DATA_WRAP(T1, T2)
> +#define T              TEST_UNARY_STRUCT_DECL(T1, T2)
> +#define RUN_UNARY(x)   RUN_SAT_U_TRUC_FMT_3_WRAP(T1, T2, x)
> +
> +#include "scalar_sat_unary.h"
> diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c
> b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c
> new file mode 100644
> index 00000000000..a29e887aeeb
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c
> @@ -0,0 +1,16 @@
> +/* { dg-do run { target { riscv_v } } } */
> +/* { dg-additional-options "-std=c99" } */
> +
> +#include "sat_arith.h"
> +#include "sat_arith_data.h"
> +
> +#define T1 uint16_t
> +#define T2 uint32_t
> +
> +DEF_SAT_U_TRUC_FMT_3_WRAP(T1, T2)
> +
> +#define DATA           TEST_UNARY_DATA_WRAP(T1, T2)
> +#define T              TEST_UNARY_STRUCT_DECL(T1, T2)
> +#define RUN_UNARY(x)   RUN_SAT_U_TRUC_FMT_3_WRAP(T1, T2, x)
> +
> +#include "scalar_sat_unary.h"
> --
> 2.43.0
>
>

  reply	other threads:[~2024-08-17 13:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-17 11:36 [PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 2 pan2.li
2024-08-17 11:36 ` [PATCH v1 2/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 3 pan2.li
2024-08-17 13:54   ` Kito Cheng [this message]
2024-08-17 13:53 ` [PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 2 Kito Cheng

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=CA+yXCZCy8NDXESbuhNsKBbcLz_nwipr1VDCdA8sx7hvm+mHUgw@mail.gmail.com \
    --to=kito.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=juzhe.zhong@rivai.ai \
    --cc=pan2.li@intel.com \
    --cc=rdapp.gcc@gmail.com \
    /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).