From patchwork Thu Oct 10 08:33:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1995336 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=WBt1MBqc; 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 4XPNRR4PGpz1xsv for ; Thu, 10 Oct 2024 19:37:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE0553857C7F for ; Thu, 10 Oct 2024 08:37:21 +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 [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id A5F3B3857C47 for ; Thu, 10 Oct 2024 08:35:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5F3B3857C47 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 A5F3B3857C47 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549337; cv=none; b=q5N8TfsiRi1tvR0wQIj4+oWTGaRcJjpLBFhFvTtDCafeimg/ZbLvCaslQ6Zo7u/JtOTasBkeuHWY+GP7Ncd19UTeRK3Gq3UnDsKxQ6h59LUGPHskON4fWMiWnWubjfMGfT/gyU2rZ+K9GRlPySPM7G3xJKUxsNBIsi6dNrEglqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549337; c=relaxed/simple; bh=xZtAbVIqo8pqnh4Mo9ZpweUv+6cW8b8F5YZi0twPfMo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=X3PBZ7ug4QWir7lTafFj+wRiSPqQr8Gbz4V5CGPfjYUa7Kg5+31hGGCgFvcQ2VliSTDELTiqXUuTOcQGAbhf4BALQ+ZL0Wl2JCoi4305pECzrxOy2gojmrfCGqe40fstHbD4hF5+LzNTHbTIyj2cvxeUQL8dtPgaczrVmlOf2Vc= 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=1728549334; x=1760085334; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xZtAbVIqo8pqnh4Mo9ZpweUv+6cW8b8F5YZi0twPfMo=; b=WBt1MBqcsWBzagA7mJGh/ifK6SuGEGwu/n0SCOy/od9TRFpRkvoTnfY3 7nC+W+seYplajosWP9NoWDdHlcZygcv3JyXgQ0HQaoaDhVk3+oI8McEic AfAywP0jdFMphXGethA3XNroBmxpqnn1VvQD/MlyrbC3ybS4l28UhCISD 0GzYHk8STxaOz7HVFpDBVjA0eruASfkA/EIoPHLWbzvC2DtgWfp1tkh9P 67xsuZQkiGEDXeWmEEMU8N0wTjzI2Zf3kSmlFP2kedI8SuDWFnpR/hYgT eopAjjxR4rE3IHY3GFZ13xiBWFDYfdYEbmCr3m1qdjv+xY9QUuNW5g7qW g==; X-CSE-ConnectionGUID: zb71fG35RL6NPHxhpteNJA== X-CSE-MsgGUID: 3F7sY4VKT1ehYQ3tw3BCXw== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="39255837" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="39255837" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 01:35:32 -0700 X-CSE-ConnectionGUID: Nzx+akghTGCUgmAddr9RJQ== X-CSE-MsgGUID: n/ip2PASRy2n9ZFWjHz/Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="81095357" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa004.fm.intel.com with ESMTP; 10 Oct 2024 01:35:28 -0700 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1 1/4] RISC-V: Add testcases for form 5 of scalar signed SAT_TRUNC Date: Thu, 10 Oct 2024 16:33:58 +0800 Message-ID: <20241010083401.1716177-1-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 5: #define DEF_SAT_S_TRUNC_FMT_5(NT, WT, NT_MIN, NT_MAX) \ NT __attribute__((noinline)) \ sat_s_trunc_##WT##_to_##NT##_fmt_5 (WT x) \ { \ NT trunc = (NT)x; \ return (WT)NT_MIN > x || x > (WT)NT_MAX \ ? x < 0 ? NT_MIN : NT_MAX \ : trunc; \ } 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/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat_s_trunc-5-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-5-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-5-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-5-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-5-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-5-i64-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-5-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-5-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-5-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-5-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-5-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-run-5-i64-to-i8.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- gcc/testsuite/gcc.target/riscv/sat_arith.h | 15 ++++++++++ .../riscv/sat_s_trunc-5-i16-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-5-i32-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-5-i32-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-5-i64-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-5-i64-to-i32.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-5-i64-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-run-5-i16-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-5-i32-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-5-i32-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-5-i64-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-5-i64-to-i32.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-5-i64-to-i8.c | 16 +++++++++++ 13 files changed, 271 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i8.c diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index 0b3d0ea7073..e3c01724f07 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -513,6 +513,18 @@ sat_s_trunc_##WT##_to_##NT##_fmt_4 (WT x) \ #define DEF_SAT_S_TRUNC_FMT_4_WRAP(NT, WT, NT_MIN, NT_MAX) \ DEF_SAT_S_TRUNC_FMT_4(NT, WT, NT_MIN, NT_MAX) +#define DEF_SAT_S_TRUNC_FMT_5(NT, WT, NT_MIN, NT_MAX) \ +NT __attribute__((noinline)) \ +sat_s_trunc_##WT##_to_##NT##_fmt_5 (WT x) \ +{ \ + NT trunc = (NT)x; \ + return (WT)NT_MIN > x || x > (WT)NT_MAX \ + ? x < 0 ? NT_MIN : NT_MAX \ + : trunc; \ +} +#define DEF_SAT_S_TRUNC_FMT_5_WRAP(NT, WT, NT_MIN, NT_MAX) \ + DEF_SAT_S_TRUNC_FMT_5(NT, WT, NT_MIN, NT_MAX) + #define RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_1 (x) #define RUN_SAT_S_TRUNC_FMT_1_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) @@ -525,4 +537,7 @@ sat_s_trunc_##WT##_to_##NT##_fmt_4 (WT x) \ #define RUN_SAT_S_TRUNC_FMT_4(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_4 (x) #define RUN_SAT_S_TRUNC_FMT_4_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_4(NT, WT, x) +#define RUN_SAT_S_TRUNC_FMT_5(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_5 (x) +#define RUN_SAT_S_TRUNC_FMT_5_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_5(NT, WT, x) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i16-to-i8.c new file mode 100644 index 00000000000..9f48295283e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i16-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int16_t_to_int8_t_fmt_5: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_5(int8_t, int16_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i16.c new file mode 100644 index 00000000000..abf1768ebc9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int32_t_to_int16_t_fmt_5: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_5(int16_t, int32_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i8.c new file mode 100644 index 00000000000..5cc7b32b422 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i32-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int32_t_to_int8_t_fmt_5: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_5(int8_t, int32_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i16.c new file mode 100644 index 00000000000..835bee5a1f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int64_t_to_int16_t_fmt_5: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_5(int16_t, int64_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i32.c new file mode 100644 index 00000000000..1c4ad98d327 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i32.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int32_t_fmt_5: +** li\s+[atx][0-9]+,\s*-2147483648 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext\.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_5(int32_t, int64_t, INT32_MIN, INT32_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i8.c new file mode 100644 index 00000000000..bdf5ba26924 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-5-i64-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int8_t_fmt_5: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_5(int8_t, int64_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i16-to-i8.c new file mode 100644 index 00000000000..191116695dd --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i16-to-i8.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 int8_t +#define T2 int16_t + +DEF_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i16.c new file mode 100644 index 00000000000..28116eb3cd7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i16.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 int16_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i8.c new file mode 100644 index 00000000000..54b1ffbbaed --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i32-to-i8.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 int8_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i16.c new file mode 100644 index 00000000000..633417ba383 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i16.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 int16_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i32.c new file mode 100644 index 00000000000..c5e4e4a0b64 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i32.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 int32_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, INT32_MIN, INT32_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i8.c new file mode 100644 index 00000000000..9acbee073a3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-5-i64-to-i8.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 int8_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_5_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" From patchwork Thu Oct 10 08:33:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1995333 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=jBQZOZcI; 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 4XPNQ43r8lz1xsv for ; Thu, 10 Oct 2024 19:36:12 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7748A385780C for ; Thu, 10 Oct 2024 08:36:10 +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 [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id 154D63857C58 for ; Thu, 10 Oct 2024 08:35:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 154D63857C58 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 154D63857C58 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549340; cv=none; b=J8w/3W4wZKEkjxXET8/Yi/+DbA9237dP3S9cxnmj1FuHMabU3DMbfDBlOuVvH87gY1cOYXwL1VuVvnY1DqgkduEFoYIrVzblZ4KKCKjP5fgxXs9MxKbbQUWEducHbMCszMOjJJl9dsTCB8BBzuzNRgoVh6UblvqcMyMIC+myMf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549340; c=relaxed/simple; bh=2lwOD6Yl7HmvYQkSkkcTBsH0Qox4SFkZXRdJ1cc7x24=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=I2kjgimTDOTyaZFAMqRoNUHEm99CBGv4PW4LZsfFrgoi5rT/QjIDzA7s5xJeYZ/Ul87INIxhUPXqVLGbQJyIG9EkpzTV0Dmt9R3o8TEcycxNTs4YUC6HIOFjxAg5V/A3sXUMp6cz14uw6b1Ub+7IM5AVsUoQBCJoL8z2fbdsa2k= 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=1728549336; x=1760085336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2lwOD6Yl7HmvYQkSkkcTBsH0Qox4SFkZXRdJ1cc7x24=; b=jBQZOZcICDv34Bl0PDOYDUXkbtq+GsVsHkmj5BF8X0EfKLfcfokA+JMJ CZhdW0HWtS3BLZH+mMJOjuQTotKHu0yJGdtv4shyVfUeNJh152aH0QuCE 3GzTL3w/d81GqDf39ZmU7NMQlbLbQReP1xsp535ONyNJODnqBj5pmZyEI qeyUhLQ8E49PsJriYuJgkRO8hDMKfxRlp61tm8OCRdwSTuzx9BPXAEU4U 2uJajNvbpxAdfvAiWGZA7A4VWgSrKnpfSyjNV3MzNHVsF2sWnyhD8wI9Y 2HY/dxhfoGWQuOlsCuXm1u0bLpUtS7WwOEAJFQTYb18z86mD6ntmyZuEP w==; X-CSE-ConnectionGUID: cPTYD3uWRWqbO7BlgjCDvA== X-CSE-MsgGUID: StLCuc6yRNaa7zkn7WUoow== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="39255845" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="39255845" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 01:35:33 -0700 X-CSE-ConnectionGUID: spgBaSJHSLyPrns/5WVd/w== X-CSE-MsgGUID: FUbGkeS1Qdqc0KaIByMsZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="81095382" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa004.fm.intel.com with ESMTP; 10 Oct 2024 01:35:31 -0700 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1 2/4] RISC-V: Add testcases for form 6 of scalar signed SAT_TRUNC Date: Thu, 10 Oct 2024 16:33:59 +0800 Message-ID: <20241010083401.1716177-2-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241010083401.1716177-1-pan2.li@intel.com> References: <20241010083401.1716177-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 6: #define DEF_SAT_S_TRUNC_FMT_6(NT, WT, NT_MIN, NT_MAX) \ NT __attribute__((noinline)) \ sat_s_trunc_##WT##_to_##NT##_fmt_6 (WT x) \ { \ NT trunc = (NT)x; \ return (WT)NT_MIN >= x || x > (WT)NT_MAX \ ? x < 0 ? NT_MIN : NT_MAX \ : trunc; \ } 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/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat_s_trunc-6-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-6-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-6-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-6-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-6-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-6-i64-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-6-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-6-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-6-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-6-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-6-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-run-6-i64-to-i8.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- gcc/testsuite/gcc.target/riscv/sat_arith.h | 15 ++++++++++ .../riscv/sat_s_trunc-6-i16-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-6-i32-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-6-i32-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-6-i64-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-6-i64-to-i32.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-6-i64-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-run-6-i16-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-6-i32-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-6-i32-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-6-i64-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-6-i64-to-i32.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-6-i64-to-i8.c | 16 +++++++++++ 13 files changed, 271 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i8.c diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index e3c01724f07..7a5110248f4 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -525,6 +525,18 @@ sat_s_trunc_##WT##_to_##NT##_fmt_5 (WT x) \ #define DEF_SAT_S_TRUNC_FMT_5_WRAP(NT, WT, NT_MIN, NT_MAX) \ DEF_SAT_S_TRUNC_FMT_5(NT, WT, NT_MIN, NT_MAX) +#define DEF_SAT_S_TRUNC_FMT_6(NT, WT, NT_MIN, NT_MAX) \ +NT __attribute__((noinline)) \ +sat_s_trunc_##WT##_to_##NT##_fmt_6 (WT x) \ +{ \ + NT trunc = (NT)x; \ + return (WT)NT_MIN >= x || x > (WT)NT_MAX \ + ? x < 0 ? NT_MIN : NT_MAX \ + : trunc; \ +} +#define DEF_SAT_S_TRUNC_FMT_6_WRAP(NT, WT, NT_MIN, NT_MAX) \ + DEF_SAT_S_TRUNC_FMT_6(NT, WT, NT_MIN, NT_MAX) + #define RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_1 (x) #define RUN_SAT_S_TRUNC_FMT_1_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) @@ -540,4 +552,7 @@ sat_s_trunc_##WT##_to_##NT##_fmt_5 (WT x) \ #define RUN_SAT_S_TRUNC_FMT_5(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_5 (x) #define RUN_SAT_S_TRUNC_FMT_5_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_5(NT, WT, x) +#define RUN_SAT_S_TRUNC_FMT_6(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_6 (x) +#define RUN_SAT_S_TRUNC_FMT_6_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_6(NT, WT, x) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i16-to-i8.c new file mode 100644 index 00000000000..3961eae2b9b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i16-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int16_t_to_int8_t_fmt_6: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_6(int8_t, int16_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i16.c new file mode 100644 index 00000000000..2cebde72db3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int32_t_to_int16_t_fmt_6: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_6(int16_t, int32_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i8.c new file mode 100644 index 00000000000..994bd2878a4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i32-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int32_t_to_int8_t_fmt_6: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_6(int8_t, int32_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i16.c new file mode 100644 index 00000000000..397f6e7fa48 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int64_t_to_int16_t_fmt_6: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_6(int16_t, int64_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i32.c new file mode 100644 index 00000000000..c63626aaa7d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i32.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int32_t_fmt_6: +** li\s+[atx][0-9]+,\s*-2147483648 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext\.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_6(int32_t, int64_t, INT32_MIN, INT32_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i8.c new file mode 100644 index 00000000000..bd2dc171f45 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-6-i64-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int8_t_fmt_6: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_6(int8_t, int64_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i16-to-i8.c new file mode 100644 index 00000000000..db1a6985732 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i16-to-i8.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 int8_t +#define T2 int16_t + +DEF_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i16.c new file mode 100644 index 00000000000..e6b52d4cab1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i16.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 int16_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i8.c new file mode 100644 index 00000000000..d83836db406 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i32-to-i8.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 int8_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i16.c new file mode 100644 index 00000000000..e910edff0f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i16.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 int16_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i32.c new file mode 100644 index 00000000000..98dd0c2cce1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i32.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 int32_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, INT32_MIN, INT32_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i8.c new file mode 100644 index 00000000000..b843300728e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-6-i64-to-i8.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 int8_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_6_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" From patchwork Thu Oct 10 08:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1995337 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=Dit18vE/; 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 4XPNSZ6GzJz1xsv for ; Thu, 10 Oct 2024 19:38:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E80E33857BA9 for ; Thu, 10 Oct 2024 08:38:20 +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 [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id 4999C3857C7A for ; Thu, 10 Oct 2024 08:35:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4999C3857C7A 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 4999C3857C7A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549341; cv=none; b=NiBgmYgvHqEVv3WKlx3ltFrIjgxbSlfENPAmUi+YXOY3VFKi/GhH/EX7MmdqvcaPbmDKnMtpPy4abF4F11aPP2G5ca1zSLdJbN3MlK1JxvQbq1WHesyYfLvc61ajQdGLnr9RK3oAlt9i9nJZMfYwDBEh9fjAoBZo3eFIMakOeig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549341; c=relaxed/simple; bh=ABcrqtsxXufn4fGZnu6gT8hkFnSD3Aecde8QQAYUxh8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HWHsNnL9V5xFPl734B4ajG2f9ig66HsvATLS3qom4nXx1ufvQZVseAKCBJ+jc4zNkrJzj3jN3LNG57AOIX20qBMFtwsD+jlkAfcw7V9xpAfsI9Z1qXFpiav90+3rW3+W749pPcz6GN/fx8w/kQEuKdZTqS4/pj1lf5btZVqDVPA= 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=1728549337; x=1760085337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ABcrqtsxXufn4fGZnu6gT8hkFnSD3Aecde8QQAYUxh8=; b=Dit18vE/dMRYSmRoX+Nxsb2Lw1BZxS//bxyslF+MN/mydgH0ugHxXt77 LgfckD7HTw4y+CBoaaaL/iWabckPy17qn+jSjvlFw187WMXSd8upCu+MS lgH9kfiuwaWF6vI0u4/PS09URAS7I+1r6mi6MQMzdsT63zNISUtwuQXVb HVdOHQ5y7dKtTCvDa91fweCnphTq5h2Vezx/DA1bkxFbAhORFYS4acait L3s4DDiqXo9kZYHPvUozChnUhi8D7KWV7878/jE1Pup+n4iEirztN6AkC XnkSlx8a30dqpCgChEk8UgXvKSAAG/c8ZDfQYP4Af78oPjFLppIuqO4cF Q==; X-CSE-ConnectionGUID: 5mjo2HSSRHyAGjszOgn3mg== X-CSE-MsgGUID: 3PkiyrkyQK+OjrSEALoMfQ== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="39255852" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="39255852" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 01:35:35 -0700 X-CSE-ConnectionGUID: iX8etD9STYilUxAAXxuXLQ== X-CSE-MsgGUID: mwwbmtK1TLG4G6l+nuuhhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="81095401" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa004.fm.intel.com with ESMTP; 10 Oct 2024 01:35:33 -0700 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1 3/4] RISC-V: Add testcases for form 7 of scalar signed SAT_TRUNC Date: Thu, 10 Oct 2024 16:34:00 +0800 Message-ID: <20241010083401.1716177-3-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241010083401.1716177-1-pan2.li@intel.com> References: <20241010083401.1716177-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 7: #define DEF_SAT_S_TRUNC_FMT_7(NT, WT, NT_MIN, NT_MAX) \ NT __attribute__((noinline)) \ sat_s_trunc_##WT##_to_##NT##_fmt_7 (WT x) \ { \ NT trunc = (NT)x; \ return (WT)NT_MIN >= x || x >= (WT)NT_MAX \ ? x < 0 ? NT_MIN : NT_MAX \ : trunc; \ } 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/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat_s_trunc-7-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-7-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-7-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-7-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-7-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-7-i64-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-7-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-7-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-7-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-7-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-7-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-run-7-i64-to-i8.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- gcc/testsuite/gcc.target/riscv/sat_arith.h | 15 ++++++++++ .../riscv/sat_s_trunc-7-i16-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-7-i32-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-7-i32-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-7-i64-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-7-i64-to-i32.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-7-i64-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-run-7-i16-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-7-i32-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-7-i32-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-7-i64-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-7-i64-to-i32.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-7-i64-to-i8.c | 16 +++++++++++ 13 files changed, 271 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i8.c diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index 7a5110248f4..189babd22f1 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -537,6 +537,18 @@ sat_s_trunc_##WT##_to_##NT##_fmt_6 (WT x) \ #define DEF_SAT_S_TRUNC_FMT_6_WRAP(NT, WT, NT_MIN, NT_MAX) \ DEF_SAT_S_TRUNC_FMT_6(NT, WT, NT_MIN, NT_MAX) +#define DEF_SAT_S_TRUNC_FMT_7(NT, WT, NT_MIN, NT_MAX) \ +NT __attribute__((noinline)) \ +sat_s_trunc_##WT##_to_##NT##_fmt_7 (WT x) \ +{ \ + NT trunc = (NT)x; \ + return (WT)NT_MIN >= x || x >= (WT)NT_MAX \ + ? x < 0 ? NT_MIN : NT_MAX \ + : trunc; \ +} +#define DEF_SAT_S_TRUNC_FMT_7_WRAP(NT, WT, NT_MIN, NT_MAX) \ + DEF_SAT_S_TRUNC_FMT_7(NT, WT, NT_MIN, NT_MAX) + #define RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_1 (x) #define RUN_SAT_S_TRUNC_FMT_1_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) @@ -555,4 +567,7 @@ sat_s_trunc_##WT##_to_##NT##_fmt_6 (WT x) \ #define RUN_SAT_S_TRUNC_FMT_6(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_6 (x) #define RUN_SAT_S_TRUNC_FMT_6_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_6(NT, WT, x) +#define RUN_SAT_S_TRUNC_FMT_7(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_7 (x) +#define RUN_SAT_S_TRUNC_FMT_7_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_7(NT, WT, x) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i16-to-i8.c new file mode 100644 index 00000000000..b931bec4ac6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i16-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int16_t_to_int8_t_fmt_7: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_7(int8_t, int16_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i16.c new file mode 100644 index 00000000000..d2092d08876 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int32_t_to_int16_t_fmt_7: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_7(int16_t, int32_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i8.c new file mode 100644 index 00000000000..21f76836270 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i32-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int32_t_to_int8_t_fmt_7: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_7(int8_t, int32_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i16.c new file mode 100644 index 00000000000..45e449d6397 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int64_t_to_int16_t_fmt_7: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_7(int16_t, int64_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i32.c new file mode 100644 index 00000000000..97edc7812a8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i32.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int32_t_fmt_7: +** li\s+[atx][0-9]+,\s*-2147483648 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext\.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_7(int32_t, int64_t, INT32_MIN, INT32_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i8.c new file mode 100644 index 00000000000..e54a8f4786b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-7-i64-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int8_t_fmt_7: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_7(int8_t, int64_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i16-to-i8.c new file mode 100644 index 00000000000..ab51ad5edba --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i16-to-i8.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 int8_t +#define T2 int16_t + +DEF_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i16.c new file mode 100644 index 00000000000..9b2c5258942 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i16.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 int16_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i8.c new file mode 100644 index 00000000000..ab409f2bc18 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i32-to-i8.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 int8_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i16.c new file mode 100644 index 00000000000..90139529f1e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i16.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 int16_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i32.c new file mode 100644 index 00000000000..67e19e713bc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i32.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 int32_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, INT32_MIN, INT32_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i8.c new file mode 100644 index 00000000000..a573706caeb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-7-i64-to-i8.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 int8_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_7_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" From patchwork Thu Oct 10 08:34:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1995334 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=noUzlCOH; 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 4XPNQ55WQCz1xvW for ; Thu, 10 Oct 2024 19:36:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF80E385701E for ; Thu, 10 Oct 2024 08:36:11 +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 [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id 090BC3857C7B for ; Thu, 10 Oct 2024 08:35:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 090BC3857C7B 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 090BC3857C7B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549343; cv=none; b=uuJoc6q2k00GhmIv8kPkly9nqxxa64P4i4nmJJjiu41FXpvJkWAgWCSOaF7ObMSbUsPRQv7O/RBPNzYoyC8i062PUXL9JNZ2tMz4RL0/d08r9nAec0Q0SxWvKJWzQdgTmGpnF64k6DtFyIHR0aGeveXGxiMbAFzy6noYivdKQKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728549343; c=relaxed/simple; bh=P104syi31+j0fKH0Ibp3Le6nwoEemtAhYCVgBAnqivk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DZqrg6FVo0k0KC5B7lHph6A8rP6kDi7z2YL64lF+dV5itglv7Qwe7u6h67yFs2Ih4iI/v+w3pOqJDP3ahmGcbvMMFdb5fbZfikilLk5+O9rg393NAcDK0/YwL6rNw+8WyJOwiIdYBes4xxYaSjjo6OUI+iL3MSVzmX3rfdAtKts= 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=1728549339; x=1760085339; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P104syi31+j0fKH0Ibp3Le6nwoEemtAhYCVgBAnqivk=; b=noUzlCOH65PgsJP2hHOZ1bnBmvt6mX/Z8/RlgwiH9PlgRm89eNkcstQA 38G3l38u3D2xUHLkOXlmy6/b2Wn1jb/cZ/41L4Phhha62zmoWfszmjTnn gRLrR0CedCqGjy1JpKhZ9wliZtwel9w88Q1Y67GsG0OJhGB4GjoaJjrB0 gp02prFzlHKX00t5MG72nKrdmSAP6mtwqOLGcSxj/KzbNmy2VKKtzoaG0 qGopUkf4XbDaxGOgVv5Ou+JGjOd+18uIvfpOWqwoUohoPsV9EU7momBUg ah+Pe8H+JoSOh5y6g9zEZe4GFDnaiwZ+P+fnxOY34ZrNLSyFn/boU0rev A==; X-CSE-ConnectionGUID: pgfu5fYsQYKubhV1kxSXMg== X-CSE-MsgGUID: gx4C/hZeSlWI2qS9pH4MFQ== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="39255858" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="39255858" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 01:35:38 -0700 X-CSE-ConnectionGUID: Aq9WuSBXQMau4N8HgfE98w== X-CSE-MsgGUID: zDtJxFExSvSZG5e/Ypt38Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="81095418" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa004.fm.intel.com with ESMTP; 10 Oct 2024 01:35:35 -0700 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1 4/4] RISC-V: Add testcases for form 8 of scalar signed SAT_TRUNC Date: Thu, 10 Oct 2024 16:34:01 +0800 Message-ID: <20241010083401.1716177-4-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241010083401.1716177-1-pan2.li@intel.com> References: <20241010083401.1716177-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 8: #define DEF_SAT_S_TRUNC_FMT_8(NT, WT, NT_MIN, NT_MAX) \ NT __attribute__((noinline)) \ sat_s_trunc_##WT##_to_##NT##_fmt_8 (WT x) \ { \ NT trunc = (NT)x; \ return (WT)NT_MIN > x || x >= (WT)NT_MAX \ ? x < 0 ? NT_MIN : NT_MAX \ : trunc; \ } 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/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat_s_trunc-8-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-8-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-8-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-8-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-8-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-8-i64-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-8-i16-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-8-i32-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-8-i32-to-i8.c: New test. * gcc.target/riscv/sat_s_trunc-run-8-i64-to-i16.c: New test. * gcc.target/riscv/sat_s_trunc-run-8-i64-to-i32.c: New test. * gcc.target/riscv/sat_s_trunc-run-8-i64-to-i8.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- gcc/testsuite/gcc.target/riscv/sat_arith.h | 15 ++++++++++ .../riscv/sat_s_trunc-8-i16-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-8-i32-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-8-i32-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-8-i64-to-i16.c | 28 +++++++++++++++++++ .../riscv/sat_s_trunc-8-i64-to-i32.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-8-i64-to-i8.c | 26 +++++++++++++++++ .../riscv/sat_s_trunc-run-8-i16-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-8-i32-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-8-i32-to-i8.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-8-i64-to-i16.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-8-i64-to-i32.c | 16 +++++++++++ .../riscv/sat_s_trunc-run-8-i64-to-i8.c | 16 +++++++++++ 13 files changed, 271 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i16-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i8.c diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index 189babd22f1..2cbd1f18c8d 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -549,6 +549,18 @@ sat_s_trunc_##WT##_to_##NT##_fmt_7 (WT x) \ #define DEF_SAT_S_TRUNC_FMT_7_WRAP(NT, WT, NT_MIN, NT_MAX) \ DEF_SAT_S_TRUNC_FMT_7(NT, WT, NT_MIN, NT_MAX) +#define DEF_SAT_S_TRUNC_FMT_8(NT, WT, NT_MIN, NT_MAX) \ +NT __attribute__((noinline)) \ +sat_s_trunc_##WT##_to_##NT##_fmt_8 (WT x) \ +{ \ + NT trunc = (NT)x; \ + return (WT)NT_MIN > x || x >= (WT)NT_MAX \ + ? x < 0 ? NT_MIN : NT_MAX \ + : trunc; \ +} +#define DEF_SAT_S_TRUNC_FMT_8_WRAP(NT, WT, NT_MIN, NT_MAX) \ + DEF_SAT_S_TRUNC_FMT_8(NT, WT, NT_MIN, NT_MAX) + #define RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_1 (x) #define RUN_SAT_S_TRUNC_FMT_1_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_1(NT, WT, x) @@ -570,4 +582,7 @@ sat_s_trunc_##WT##_to_##NT##_fmt_7 (WT x) \ #define RUN_SAT_S_TRUNC_FMT_7(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_7 (x) #define RUN_SAT_S_TRUNC_FMT_7_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_7(NT, WT, x) +#define RUN_SAT_S_TRUNC_FMT_8(NT, WT, x) sat_s_trunc_##WT##_to_##NT##_fmt_8 (x) +#define RUN_SAT_S_TRUNC_FMT_8_WRAP(NT, WT, x) RUN_SAT_S_TRUNC_FMT_8(NT, WT, x) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i16-to-i8.c new file mode 100644 index 00000000000..cf1916b958c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i16-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int16_t_to_int8_t_fmt_8: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_8(int8_t, int16_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i16.c new file mode 100644 index 00000000000..f4c46f04079 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int32_t_to_int16_t_fmt_8: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_8(int16_t, int32_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i8.c new file mode 100644 index 00000000000..6c026e63d26 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i32-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int32_t_to_int8_t_fmt_8: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_8(int8_t, int32_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i16.c new file mode 100644 index 00000000000..cc6e1a6722e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i16.c @@ -0,0 +1,28 @@ +/* { 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_s_trunc_int64_t_to_int16_t_fmt_8: +** li\s+[atx][0-9]+,\s*32768 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** li\s+[atx][0-9]+,\s*-32768 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*16 +** sraiw\s+a0,\s*a0,\s*16 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_8(int16_t, int64_t, INT16_MIN, INT16_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i32.c new file mode 100644 index 00000000000..0ef940d8251 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i32.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int32_t_fmt_8: +** li\s+[atx][0-9]+,\s*-2147483648 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xor\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext\.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_8(int32_t, int64_t, INT32_MIN, INT32_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i8.c new file mode 100644 index 00000000000..c62bd5ee49c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-8-i64-to-i8.c @@ -0,0 +1,26 @@ +/* { 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_s_trunc_int64_t_to_int8_t_fmt_8: +** slti\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** li\s+[atx][0-9]+,\s*-128 +** slt\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** neg\s+[atx][0-9]+,\s*[atx][0-9]+ +** srai\s+[atx][0-9]+,\s*[atx][0-9]+,\s*63 +** xori\s+[atx][0-9]+,\s*[atx][0-9]+,\s*127 +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** and\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** or\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slliw\s+a0,\s*a0,\s*24 +** sraiw\s+a0,\s*a0,\s*24 +** ret +*/ +DEF_SAT_S_TRUNC_FMT_8(int8_t, int64_t, INT8_MIN, INT8_MAX) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i16-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i16-to-i8.c new file mode 100644 index 00000000000..dbd70de2569 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i16-to-i8.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 int8_t +#define T2 int16_t + +DEF_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i16.c new file mode 100644 index 00000000000..25bb42fb0ab --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i16.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 int16_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i8.c new file mode 100644 index 00000000000..7c71b3d42aa --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i32-to-i8.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 int8_t +#define T2 int32_t + +DEF_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i16.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i16.c new file mode 100644 index 00000000000..61392b569e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i16.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 int16_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, INT16_MIN, INT16_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i32.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i32.c new file mode 100644 index 00000000000..b47e5da0a29 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i32.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 int32_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, INT32_MIN, INT32_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i8.c b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i8.c new file mode 100644 index 00000000000..1cd7f8049b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_s_trunc-run-8-i64-to-i8.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 int8_t +#define T2 int64_t + +DEF_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, INT8_MIN, INT8_MAX) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_S_TRUNC_FMT_8_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h"