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"