From patchwork Tue Jun 25 12:40:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1952106 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=LYnxzhvu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W7kwH52YTz20Z9 for ; Tue, 25 Jun 2024 22:41:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01B3A386182A for ; Tue, 25 Jun 2024 12:41:18 +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 DB29D387085C for ; Tue, 25 Jun 2024 12:40:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB29D387085C 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 DB29D387085C 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=1719319251; cv=none; b=IHfNL3zBvis4M/SmhO7bIS9JlzLxwqvLSW7IBU92tEvVIkFPpaa5h1EYrs53IwMz8Wn1WmKqxJBTvUwiyRTBYR49IBixvO+29AN6tdJN2CRDjM/xeKS5TdFZF0YAlUQPSFBY8kMiX1OsPKOeoMqKxrDg5ChrmqC+DCHWwQ0AZak= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719319251; c=relaxed/simple; bh=FZTPfCa2yU8lA5xlKeM+fknL+SQxQ14PVVDGA2899Ts=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=lvXIZm5KuaEQFseI4E1TnkHkRyzTrbpHYE7EKQmuKBBQsLTfC7L4dBJ6edcodjgkGvCMOiBK+4dU9tEqm8jkZrZwXlilw9oklxztUanuPau1Waw8pMx9W7y20xAnn+TgJgXtgMJ/grzBOAzswPfyTKkbUL8ydRxaNVfn6j9NfIQ= 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=1719319248; x=1750855248; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=FZTPfCa2yU8lA5xlKeM+fknL+SQxQ14PVVDGA2899Ts=; b=LYnxzhvu4PW+oDUrFMfzaNuK58BEGIavuC/yt2tTOQpNeln7C5SfZJvl lqen/OOHo80Vfayb0BdygSsthfeCbt6YjMeXDJSGc+Ae1hPvI942BsXqb ZlrE8B2Gv7AJY/EvKyzKgJCPSFmMEjCF/DVMKDWabnnNM8GsiBEpjTbtJ E/wlLHEVwf857+UecIc4F1jCoJAdnyQEtlCj9KaPiqRO+Sh2s26M29f3B 8j8S6i8+I7sCBvGJ+KA0nhlk+L2u9DFui0xVMd9LRzgpTPdsWkthR/2vp MNOaw2FA3CDc6KC+GzsckMJtBx4UJH3B9H3P6zQ4mB+iC2iFrfRHs76y4 w==; X-CSE-ConnectionGUID: cY0sXaTIQX6EZIzJapHDLw== X-CSE-MsgGUID: 0+VKBQQyQDiSQi4/fhIP0w== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="20142617" X-IronPort-AV: E=Sophos;i="6.08,264,1712646000"; d="scan'208";a="20142617" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 05:40:47 -0700 X-CSE-ConnectionGUID: UfIrNmVoTZSiXTZEfWoc9w== X-CSE-MsgGUID: 41Vjhp2yTO+OhChBiqqb/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,264,1712646000"; d="scan'208";a="44077438" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by orviesa006.jf.intel.com with ESMTP; 25 Jun 2024 05:40:43 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail02.sh.intel.com (Postfix) with ESMTP id 58D1B10057E8; Tue, 25 Jun 2024 20:40:42 +0800 (CST) From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, richard.guenther@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1] RISC-V: Add testcases for vector truncate after .SAT_SUB Date: Tue, 25 Jun 2024 20:40:41 +0800 Message-Id: <20240625124041.80080-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, SCC_10_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, 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 This patch would like to add the test cases of the vector truncate after .SAT_SUB. Aka: #define DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T) \ void __attribute__((noinline)) \ vec_sat_u_sub_trunc_##OUT_T##_fmt_1 (OUT_T *out, IN_T *op_1, IN_T y, \ unsigned limit) \ { \ unsigned i; \ for (i = 0; i < limit; i++) \ { \ IN_T x = op_1[i]; \ out[i] = (OUT_T)(x >= y ? x - y : 0); \ } \ } The below 3 cases are included. DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(uint8_t, uint16_t) DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(uint16_t, uint32_t) DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(uint32_t, uint64_t) gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h: Add helper test macros. * gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_scalar.h: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-1.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-2.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-3.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-1.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-2.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-3.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- .../riscv/rvv/autovec/binop/vec_sat_arith.h | 19 +++++ .../rvv/autovec/binop/vec_sat_binary_scalar.h | 27 +++++++ .../rvv/autovec/binop/vec_sat_u_sub_trunc-1.c | 21 ++++++ .../rvv/autovec/binop/vec_sat_u_sub_trunc-2.c | 21 ++++++ .../rvv/autovec/binop/vec_sat_u_sub_trunc-3.c | 21 ++++++ .../autovec/binop/vec_sat_u_sub_trunc-run-1.c | 74 +++++++++++++++++++ .../autovec/binop/vec_sat_u_sub_trunc-run-2.c | 74 +++++++++++++++++++ .../autovec/binop/vec_sat_u_sub_trunc-run-3.c | 74 +++++++++++++++++++ 8 files changed, 331 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_scalar.h create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-3.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-3.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h index d5c81fbe5a9..a3116033fb3 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h @@ -310,4 +310,23 @@ vec_sat_u_sub_##T##_fmt_10 (T *out, T *op_1, T *op_2, unsigned limit) \ #define RUN_VEC_SAT_U_SUB_FMT_10(T, out, op_1, op_2, N) \ vec_sat_u_sub_##T##_fmt_10(out, op_1, op_2, N) +/******************************************************************************/ +/* Saturation Sub Truncated (Unsigned and Signed) */ +/******************************************************************************/ +#define DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_trunc_##OUT_T##_fmt_1 (OUT_T *out, IN_T *op_1, IN_T y, \ + unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + IN_T x = op_1[i]; \ + out[i] = (OUT_T)(x >= y ? x - y : 0); \ + } \ +} + +#define RUN_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T, out, op_1, y, N) \ + vec_sat_u_sub_trunc_##OUT_T##_fmt_1(out, op_1, y, N) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_scalar.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_scalar.h new file mode 100644 index 00000000000..c79b180054e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_scalar.h @@ -0,0 +1,27 @@ +#ifndef HAVE_DEFINED_VEC_SAT_BINARY_SCALAR +#define HAVE_DEFINED_VEC_SAT_BINARY_SCALAR + +int +main () +{ + unsigned i, k; + OUT_T out[N]; + + for (i = 0; i < sizeof (expect_data) / sizeof (expect_data[0]); i++) + { + IN_T *op_1 = op_1_data[i]; + IN_T op_2 = op_2_data[i]; + OUT_T *expect = expect_data[i]; + + RUN_VEC_SAT_BINARY (OUT_T, IN_T, out, op_1, op_2, N); + + for (k = 0; k < N; k++) + if (out[k] != expect[k]) + __builtin_abort (); + } + + return 0; +} + +#endif + diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-1.c new file mode 100644 index 00000000000..dd9e3999a29 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_trunc_uint8_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** vsetvli\s+zero,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma +** vncvt\.x\.x\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(uint8_t, uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-2.c new file mode 100644 index 00000000000..738d1465a01 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_trunc_uint16_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** vsetvli\s+zero,\s*zero,\s*e16,\s*mf2,\s*ta,\s*ma +** vncvt\.x\.x\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(uint16_t, uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-3.c new file mode 100644 index 00000000000..b008b21cf0c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_trunc_uint32_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** vsetvli\s+zero,\s*zero,\s*e32,\s*mf2,\s*ta,\s*ma +** vncvt\.x\.x\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(uint32_t, uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-1.c new file mode 100644 index 00000000000..324648e6e31 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-1.c @@ -0,0 +1,74 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define OUT_T uint8_t +#define IN_T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_TRUNC_FMT_1 + +DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T) + +OUT_T expect_data[][N] = { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + { + 254, 255, 4, 0, + 254, 255, 4, 0, + 254, 255, 4, 0, + 254, 255, 4, 0, + }, + { + 23, 0, 0, 2, + 23, 0, 0, 2, + 23, 0, 0, 2, + 23, 0, 0, 2, + }, + { + 254, 43, 0, 255, + 254, 43, 0, 255, + 254, 43, 0, 255, + 254, 43, 0, 255, + }, +}; + +IN_T op_1_data[][N] = { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + { + 65535, 256, 5, 0, + 65535, 256, 5, 0, + 65535, 256, 5, 0, + 65535, 256, 5, 0, + }, + { + 65535, 1024, 5, 65002, + 65535, 1024, 5, 65002, + 65535, 1024, 5, 65002, + 65535, 1024, 5, 65002, + }, + { + 65535, 300, 256, 512, + 65535, 300, 256, 512, + 65535, 300, 256, 512, + 65535, 300, 256, 512, + }, +}; + +IN_T op_2_data[] = { + 0, + 1, + 65000, + 257, +}; + +#include "vec_sat_binary_scalar.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-2.c new file mode 100644 index 00000000000..a9bf1dddf98 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-2.c @@ -0,0 +1,74 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define OUT_T uint16_t +#define IN_T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_TRUNC_FMT_1 + +DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T) + +OUT_T expect_data[][N] = { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + { + 65534, 65535, 4, 0, + 65534, 65535, 4, 0, + 65534, 65535, 4, 0, + 65534, 65535, 4, 0, + }, + { + 43, 0, 0, 2, + 43, 0, 0, 2, + 43, 0, 0, 2, + 43, 0, 0, 2, + }, + { + 65532, 34484, 0, 65535, + 65532, 34484, 0, 65535, + 65532, 34484, 0, 65535, + 65532, 34484, 0, 65535, + }, +}; + +IN_T op_1_data[][N] = { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + { + 4294967295, 65536, 5, 0, + 4294967295, 65536, 5, 0, + 4294967295, 65536, 5, 0, + 4294967295, 65536, 5, 0, + }, + { + 4294967295, 1024, 5, 4294967254, + 4294967295, 1024, 5, 4294967254, + 4294967295, 1024, 5, 4294967254, + 4294967295, 1024, 5, 4294967254, + }, + { + 4294967295, 100023, 65536, 131074, + 4294967295, 100023, 65536, 131074, + 4294967295, 100023, 65536, 131074, + 4294967295, 100023, 65536, 131074, + }, +}; + +IN_T op_2_data[] = { + 0, + 1, + 4294967252, + 65539, +}; + +#include "vec_sat_binary_scalar.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-3.c new file mode 100644 index 00000000000..1ea7467e8a6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-run-3.c @@ -0,0 +1,74 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define OUT_T uint32_t +#define IN_T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_TRUNC_FMT_1 + +DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T) + +OUT_T expect_data[][N] = { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + { + 4294967294, 4294967295, 4, 0, + 4294967294, 4294967295, 4, 0, + 4294967294, 4294967295, 4, 0, + 4294967294, 4294967295, 4, 0, + }, + { + 10, 0, 0, 2, + 10, 0, 0, 2, + 10, 0, 0, 2, + 10, 0, 0, 2, + }, + { + 4294967288, 99995992, 0, 1, + 4294967288, 99995992, 0, 1, + 4294967288, 99995992, 0, 1, + 4294967288, 99995992, 0, 1, + }, +}; + +IN_T op_1_data[][N] = { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + { + 18446744073709551615u, 4294967296, 5, 0, + 18446744073709551615u, 4294967296, 5, 0, + 18446744073709551615u, 4294967296, 5, 0, + 18446744073709551615u, 4294967296, 5, 0, + }, + { + 18446744073709551615u, 1024, 5, 18446744073709551607u, + 18446744073709551615u, 1024, 5, 18446744073709551607u, + 18446744073709551615u, 1024, 5, 18446744073709551607u, + 18446744073709551615u, 1024, 5, 18446744073709551607u, + }, + { + 18446744073709551615u, 4394963295, 65536, 4294967304, + 18446744073709551615u, 4394963295, 65536, 4294967304, + 18446744073709551615u, 4394963295, 65536, 4294967304, + 18446744073709551615u, 4394963295, 65536, 4294967304, + }, +}; + +IN_T op_2_data[] = { + 0, + 1, + 18446744073709551605u, + 4294967303, +}; + +#include "vec_sat_binary_scalar.h"