From patchwork Sat Oct 12 04:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1996349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EI/bVWUp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XQVpx4mn8z1xtp for ; Sat, 12 Oct 2024 15:28:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F28133857820 for ; Sat, 12 Oct 2024 04:28:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id A17CC3858C2B for ; Sat, 12 Oct 2024 04:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A17CC3858C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A17CC3858C2B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728707262; cv=none; b=nV+orcJeEdZedkbdYHO9IUOqH/ruNwIG+TCMhTx3h1gyGoQAyM3FPIoWM11l7Yag73OGjGAfMIyGT9uizYJViUAOM6XkmD6deIWzFMuc7cgSYRkaNsWWd3jD9O67wgjekcgQi9IiEi9eHhNGCpotp9RJ9HJ5gJLWPBr+Ut3x2hQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728707262; c=relaxed/simple; bh=a5eZgUgtUpdb4vsQgZkwV6WizspVHy+rOPskByav1nY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Bj7L+mefc49GduFtXwVIRPRzKrSIrDBtJE+caEcy6mWJ4WvSBTbsT4FcUD6esO7khu6cAb4MSvQqo10fuiMzcFsS+DHXh9EvOhMoh3up+5xSOI4JjjjfUEsx96YIWrYHH52hDaBg2ybHRlVXOwKrsuPux5jPtAEsQnE6lBIP9W0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728707260; x=1760243260; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=a5eZgUgtUpdb4vsQgZkwV6WizspVHy+rOPskByav1nY=; b=EI/bVWUpyjSQey0GpegJ1fj4QKnACFsmlm5YRZdJfXWjuDfq3hpJOJQ8 y6zYgaV0q5xImdLnum0UNzYZHyX2pK4Z4xUf9xECCU0xa28b7wJ+YOt1t /xyH+3shWrD9f92lr5ygglvwtb3JykcBBNs+sU6KWYNa53WGyYx0qAOl1 +p8UmCHsgfcsrGvxP7SA48IfpH+zuyQX+rzUEXlogKN2feTS4PZRPItCN +IkoXtI4gIuK/GoaaG+J5ftasxoCFOpjNgdtVtBhR3jDwDtX6L5RJrtMW 1MnzbsUN8Po6gZOF6+VCKgP/vRSZesI/mHQsi594pYOMHuG4c8yAzH6Xj g==; X-CSE-ConnectionGUID: JB1wfBDfSjOp3M3e4xVHlA== X-CSE-MsgGUID: Ny6YQcvKS7Cn9Y1nkRl8Lw== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="31902595" X-IronPort-AV: E=Sophos;i="6.11,197,1725346800"; d="scan'208";a="31902595" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2024 21:27:38 -0700 X-CSE-ConnectionGUID: AdyYDvFSS9qp7vG1o2s4Qg== X-CSE-MsgGUID: y6WVhmqrSl61e051PACapw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,197,1725346800"; d="scan'208";a="77189308" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 11 Oct 2024 21:27:36 -0700 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, Tamar.Christina@arm.com, juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH 1/4] RISC-V: Add testcases for form 2 of vector signed SAT_SUB Date: Sat, 12 Oct 2024 12:26:02 +0800 Message-ID: <20241012042605.3788448-1-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Pan Li Form 2: #define DEF_VEC_SAT_S_SUB_FMT_2(T, UT, MIN, MAX) \ void __attribute__((noinline)) \ vec_sat_s_sub_##T##_fmt_2 (T *out, T *op_1, T *op_2, unsigned limit) \ { \ unsigned i; \ for (i = 0; i < limit; i++) \ { \ T x = op_1[i]; \ T y = op_2[i]; \ T minus = (UT)x - (UT)y; \ out[i] = (x ^ y) >= 0 || (minus ^ x) >= 0 \ ? minus : x < 0 ? MIN : MAX; \ } \ } DEF_VEC_SAT_S_SUB_FMT_2(int8_t, uint8_t, INT8_MIN, INT8_MAX) The below test are passed for this patch. * The rv64gcv fully regression test. It is test only patch and obvious up to a point, will commit it directly if no comments in next 48H. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper macros. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i16.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i32.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i64.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i8.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i16.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i32.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i64.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i8.c: New test. Signed-off-by: Pan Li --- .../rvv/autovec/binop/vec_sat_s_sub-2-i16.c | 9 ++++++++ .../rvv/autovec/binop/vec_sat_s_sub-2-i32.c | 9 ++++++++ .../rvv/autovec/binop/vec_sat_s_sub-2-i64.c | 9 ++++++++ .../rvv/autovec/binop/vec_sat_s_sub-2-i8.c | 9 ++++++++ .../autovec/binop/vec_sat_s_sub-run-2-i16.c | 17 ++++++++++++++ .../autovec/binop/vec_sat_s_sub-run-2-i32.c | 17 ++++++++++++++ .../autovec/binop/vec_sat_s_sub-run-2-i64.c | 17 ++++++++++++++ .../autovec/binop/vec_sat_s_sub-run-2-i8.c | 17 ++++++++++++++ .../riscv/rvv/autovec/vec_sat_arith.h | 22 +++++++++++++++++++ 9 files changed, 126 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i64.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i64.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i8.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i16.c new file mode 100644 index 00000000000..dec0359c5ed --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i16.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details" } */ + +#include "../vec_sat_arith.h" + +DEF_VEC_SAT_S_SUB_FMT_2(int16_t, uint16_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ +/* { dg-final { scan-assembler-times {vssub\.vv} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i32.c new file mode 100644 index 00000000000..72b2d6778cc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i32.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details" } */ + +#include "../vec_sat_arith.h" + +DEF_VEC_SAT_S_SUB_FMT_2(int32_t, uint32_t, INT32_MIN, INT32_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ +/* { dg-final { scan-assembler-times {vssub\.vv} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i64.c new file mode 100644 index 00000000000..3ca44589e42 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i64.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details" } */ + +#include "../vec_sat_arith.h" + +DEF_VEC_SAT_S_SUB_FMT_2(int64_t, uint64_t, INT64_MIN, INT64_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ +/* { dg-final { scan-assembler-times {vssub\.vv} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i8.c new file mode 100644 index 00000000000..e3a7bfcf161 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-2-i8.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details" } */ + +#include "../vec_sat_arith.h" + +DEF_VEC_SAT_S_SUB_FMT_2(int8_t, uint8_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ +/* { dg-final { scan-assembler-times {vssub\.vv} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i16.c new file mode 100644 index 00000000000..89cd45036d1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i16.c @@ -0,0 +1,17 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "../vec_sat_arith.h" +#include "vec_sat_data.h" + +#define T int16_t +#define T1 int16_t +#define T2 uint16_t + +DEF_VEC_SAT_S_SUB_FMT_2_WRAP (T1, T2, INT16_MIN, INT16_MAX) + +#define test_data TEST_BINARY_DATA_NAME_WRAP(T, T, sssub) +#define RUN_VEC_SAT_BINARY(T, out, op_1, op_2, N) \ + RUN_VEC_SAT_S_SUB_FMT_2_WRAP(T, out, op_1, op_2, N) + +#include "vec_sat_binary_vvv_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i32.c new file mode 100644 index 00000000000..aa91300111a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i32.c @@ -0,0 +1,17 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "../vec_sat_arith.h" +#include "vec_sat_data.h" + +#define T int32_t +#define T1 int32_t +#define T2 uint32_t + +DEF_VEC_SAT_S_SUB_FMT_2_WRAP (T1, T2, INT32_MIN, INT32_MAX) + +#define test_data TEST_BINARY_DATA_NAME_WRAP(T, T, sssub) +#define RUN_VEC_SAT_BINARY(T, out, op_1, op_2, N) \ + RUN_VEC_SAT_S_SUB_FMT_2_WRAP(T, out, op_1, op_2, N) + +#include "vec_sat_binary_vvv_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i64.c new file mode 100644 index 00000000000..06107030232 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i64.c @@ -0,0 +1,17 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "../vec_sat_arith.h" +#include "vec_sat_data.h" + +#define T int64_t +#define T1 int64_t +#define T2 uint64_t + +DEF_VEC_SAT_S_SUB_FMT_2_WRAP (T1, T2, INT64_MIN, INT64_MAX) + +#define test_data TEST_BINARY_DATA_NAME_WRAP(T, T, sssub) +#define RUN_VEC_SAT_BINARY(T, out, op_1, op_2, N) \ + RUN_VEC_SAT_S_SUB_FMT_2_WRAP(T, out, op_1, op_2, N) + +#include "vec_sat_binary_vvv_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i8.c new file mode 100644 index 00000000000..3b2a24d321e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_s_sub-run-2-i8.c @@ -0,0 +1,17 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "../vec_sat_arith.h" +#include "vec_sat_data.h" + +#define T int8_t +#define T1 int8_t +#define T2 uint8_t + +DEF_VEC_SAT_S_SUB_FMT_2_WRAP (T1, T2, INT8_MIN, INT8_MAX) + +#define test_data TEST_BINARY_DATA_NAME_WRAP(T, T, sssub) +#define RUN_VEC_SAT_BINARY(T, out, op_1, op_2, N) \ + RUN_VEC_SAT_S_SUB_FMT_2_WRAP(T, out, op_1, op_2, N) + +#include "vec_sat_binary_vvv_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vec_sat_arith.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vec_sat_arith.h index a2caf335c0b..93deceec1a2 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vec_sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vec_sat_arith.h @@ -466,6 +466,23 @@ vec_sat_s_sub_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \ #define DEF_VEC_SAT_S_SUB_FMT_1_WRAP(T, UT, MIN, MAX) \ DEF_VEC_SAT_S_SUB_FMT_1(T, UT, MIN, MAX) +#define DEF_VEC_SAT_S_SUB_FMT_2(T, UT, MIN, MAX) \ +void __attribute__((noinline)) \ +vec_sat_s_sub_##T##_fmt_2 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T minus = (UT)x - (UT)y; \ + out[i] = (x ^ y) >= 0 || (minus ^ x) >= 0 \ + ? minus : x < 0 ? MIN : MAX; \ + } \ +} +#define DEF_VEC_SAT_S_SUB_FMT_2_WRAP(T, UT, MIN, MAX) \ + DEF_VEC_SAT_S_SUB_FMT_2(T, UT, MIN, MAX) + #define RUN_VEC_SAT_U_SUB_FMT_1(T, out, op_1, op_2, N) \ vec_sat_u_sub_##T##_fmt_1(out, op_1, op_2, N) @@ -506,6 +523,11 @@ vec_sat_s_sub_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \ #define RUN_VEC_SAT_S_SUB_FMT_1_WRAP(T, out, op_1, op_2, N) \ RUN_VEC_SAT_S_SUB_FMT_1(T, out, op_1, op_2, N) +#define RUN_VEC_SAT_S_SUB_FMT_2(T, out, op_1, op_2, N) \ + vec_sat_s_sub_##T##_fmt_2(out, op_1, op_2, N) +#define RUN_VEC_SAT_S_SUB_FMT_2_WRAP(T, out, op_1, op_2, N) \ + RUN_VEC_SAT_S_SUB_FMT_2(T, out, op_1, op_2, N) + /******************************************************************************/ /* Saturation Sub Truncated (Unsigned and Signed) */ /******************************************************************************/