From patchwork Thu Aug 29 08:12:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1978301 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=FVAZ6TuK; 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 4WvYvB47vmz1ydy for ; Thu, 29 Aug 2024 18:13:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6484E385C6C7 for ; Thu, 29 Aug 2024 08:13:24 +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.14]) by sourceware.org (Postfix) with ESMTPS id 9054D385EC3E for ; Thu, 29 Aug 2024 08:12:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9054D385EC3E 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 9054D385EC3E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724919183; cv=none; b=ntqa9rslKhkJ9qECgfKQ8n4xLkjazPFSIhoG221WnZEOewXUiY7YJ5DdWPrh7sNYGuzhPa0lFWM7jgdYXIK/UGDV/VtywZcw+YumVTDCEU+UdDhnDdC5p5imcFhDzc20FRwyJyZi9GduAUYnS3gHX39y7bQxQ76vPpKZNp1z/HE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724919183; c=relaxed/simple; bh=eXZigoNeh+OzwaJ9K5BWdlCTdRTDe4VDu8fIXGjv9O4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZRGD+0p/4LVpXOAdlSuUmvtY4m23QsLXC4NEOHMSM9+O04yPLFXI2SjyrMStgiIn3Jb3HQo4Nv7hkSHW2Xpo2UR2RdIBL2Rt0fG34+mS1SzloUvphwIK0VEX+1+Ke8gO/TXg9j6r6bhf1cUgmKx1F31dJiefUzrkgXjHz2ofV0s= 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=1724919180; x=1756455180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eXZigoNeh+OzwaJ9K5BWdlCTdRTDe4VDu8fIXGjv9O4=; b=FVAZ6TuKS9WwK5JwboQPV0MAROsSA0eXpGQoAq0c5FjE2eWqR3kcNWao H0T2GV0uASPlRMRz8pL/1qkZVTRtC1li+9BtFFlnsq6nmkJ/49GqwZcVl lb6phuo9vcUQtC1iAW9Nq8Pm429tVf7LNZw7fZI4GI1uXydogT+KBzWTf zueEfoBCqfbanfBrns0Ka1tm8jxtPTsphxwyxfxWGZnVU7XYNW1xpFVIu QOkcj0yBpFnOE8tcDJZS4vXp0XpZnMK5KJ80VVzk4WYUIFDGBmxiS7V1M sPJ/Cd41lDIWKjImhcRn36gY5mMDi9lm+AKVCRt3z9TphwT3ATefbdnQz Q==; X-CSE-ConnectionGUID: L7qx+6IXTKWZxW6rdxurAA== X-CSE-MsgGUID: Aai6kTmyRPqH1eEsblrREw== X-IronPort-AV: E=McAfee;i="6700,10204,11178"; a="23679971" X-IronPort-AV: E=Sophos;i="6.10,185,1719903600"; d="scan'208";a="23679971" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2024 01:12:58 -0700 X-CSE-ConnectionGUID: w+7SUeHcRPqBD2H0fYMNdQ== X-CSE-MsgGUID: jjONPCujTveAIceVIjCL5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,185,1719903600"; d="scan'208";a="63495997" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 29 Aug 2024 01:12:56 -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 v2 2/2] RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 3 Date: Thu, 29 Aug 2024 16:12:17 +0800 Message-ID: <20240829081217.3939502-2-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829081217.3939502-1-pan2.li@intel.com> References: <20240829081217.3939502-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Pan Li This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 3. Aka: Form 3: #define DEF_SAT_U_TRUC_FMT_3(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \ { \ WT max = (WT)(NT)-1; \ return x <= max ? (NT)x : (NT) max; \ } QUAD: DEF_SAT_U_TRUC_FMT_3 (uint16_t, uint64_t) DEF_SAT_U_TRUC_FMT_3 (uint8_t, uint32_t) OCT: DEF_SAT_U_TRUC_FMT_3 (uint8_t, uint64_t) The below test is passed for this patch. * The rv64gcv regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_u_trunc-16.c: New test. * gcc.target/riscv/sat_u_trunc-17.c: New test. * gcc.target/riscv/sat_u_trunc-18.c: New test. * gcc.target/riscv/sat_u_trunc-run-16.c: New test. * gcc.target/riscv/sat_u_trunc-run-17.c: New test. * gcc.target/riscv/sat_u_trunc-run-18.c: New test. Signed-off-by: Pan Li --- .../gcc.target/riscv/sat_u_trunc-16.c | 17 ++++++++++++++++ .../gcc.target/riscv/sat_u_trunc-17.c | 17 ++++++++++++++++ .../gcc.target/riscv/sat_u_trunc-18.c | 20 +++++++++++++++++++ .../gcc.target/riscv/sat_u_trunc-run-16.c | 16 +++++++++++++++ .../gcc.target/riscv/sat_u_trunc-run-17.c | 16 +++++++++++++++ .../gcc.target/riscv/sat_u_trunc-run-18.c | 16 +++++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-17.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-18.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-17.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-18.c diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-16.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-16.c new file mode 100644 index 00000000000..f91da58c0ba --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-16.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint32_t_to_uint8_t_fmt_3: +** sltiu\s+[atx][0-9]+,\s*a0,\s*255 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** andi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*0xff +** ret +*/ +DEF_SAT_U_TRUNC_FMT_3(uint8_t, uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-17.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-17.c new file mode 100644 index 00000000000..9813e1f79b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-17.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint64_t_to_uint8_t_fmt_3: +** sltiu\s+[atx][0-9]+,\s*a0,\s*255 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** andi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*0xff +** ret +*/ +DEF_SAT_U_TRUNC_FMT_3(uint8_t, uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-18.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-18.c new file mode 100644 index 00000000000..eb799849f73 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-18.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint64_t_to_uint16_t_fmt_3: +** li\s+[atx][0-9]+,\s*65536 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** sltu\s+[atx][0-9]+,\s*a0,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_TRUNC_FMT_3(uint16_t, uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-16.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-16.c new file mode 100644 index 00000000000..20ceda6852e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-16.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint8_t +#define T2 uint32_t + +DEF_SAT_U_TRUNC_FMT_3_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_3_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-17.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-17.c new file mode 100644 index 00000000000..8471c76a4aa --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-17.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint8_t +#define T2 uint64_t + +DEF_SAT_U_TRUNC_FMT_3_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_3_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-18.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-18.c new file mode 100644 index 00000000000..e868da152b3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-18.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint16_t +#define T2 uint64_t + +DEF_SAT_U_TRUNC_FMT_3_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_3_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h"