From patchwork Sat Aug 17 11:36:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1973476 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=Ip8FcZMv; 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 4WmH0f2k6Hz1yXb for ; Sat, 17 Aug 2024 21:37:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11BAB3860C3B for ; Sat, 17 Aug 2024 11:37:52 +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.11]) by sourceware.org (Postfix) with ESMTPS id D14CA3860756 for ; Sat, 17 Aug 2024 11:37:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D14CA3860756 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 D14CA3860756 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723894630; cv=none; b=nmGp84zhRlrMNcnHDK6yx8PGbGyxGZF+rek5aWsEN8aFYNCKEkEZ2X5bQM7S0Zz99uHfL2mRDSegz5MLE2c8iNWL4hzRq9UZ4ehu5w5dxYXOvVRFwnh5FfQCP+zUvbZ1IoAiXs8XtJOMpWZsUOknESHurfeNcILllQEKeH/6Zr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723894630; c=relaxed/simple; bh=iY7Rjm9MH8U56wnu1EcIIYiPStv7bVcuVG5VR6+JS0E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AG3CfmJR/kMLYcs466L3zLHG2Ea11K9fF7cjZuBaj5UVhcVUlUE+nAFqWhJWzIHK218W9SI1h0NhxsiuGBP0eJViBfTOKB2c17o3uKIHMly07ugx9/2Rb6kNodGYVpl7s0qEpi4G0oqFolQpS7p8PnDduNC6KnezNwrovSdJdS4= 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=1723894628; x=1755430628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iY7Rjm9MH8U56wnu1EcIIYiPStv7bVcuVG5VR6+JS0E=; b=Ip8FcZMvF/5wgqahQG2AYmkBXZqM6mG6tdV9ujzvjdy1++ve8cDj0Zgo lsrqYaAYvIJb0YoWIAhQzf34E25Ld4OEQEI7eKmgCPx5oMWh0PK5UzedF PX9symyEh2b7i8vGC3vxDr0bMrRJrEauSXEz+RnVhpAfh0o6A87PLj/7Q XNdOGnz9YOe3cX9H4wtVxW2u437b8QpUJjGl+PyGVP2ncXiE9065U0DNc poC9m0IVpDDy6+8JIhxBpcGihAXGnwvX2LlYFJB49Z3Zhv2XmP642HHDk YGPg7uNz0T70FY3pq8vaplpRMv/2puGKmIy+2qB/iWTCezWAH4TeX0Izt A==; X-CSE-ConnectionGUID: tL7AdADJS3iQRfrXhIEE/A== X-CSE-MsgGUID: QwOB2iwkRoKCWf2GBxFjIg== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="32814212" X-IronPort-AV: E=Sophos;i="6.10,154,1719903600"; d="scan'208";a="32814212" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2024 04:37:07 -0700 X-CSE-ConnectionGUID: wi50ZTj1T8KBucuAfxpK1A== X-CSE-MsgGUID: hV/aTXdHQQmsSVJeIo6Gsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,154,1719903600"; d="scan'208";a="64308932" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa005.fm.intel.com with ESMTP; 17 Aug 2024 04:37:05 -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/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 3 Date: Sat, 17 Aug 2024 19:36:41 +0800 Message-ID: <20240817113641.73334-2-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240817113641.73334-1-pan2.li@intel.com> References: <20240817113641.73334-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_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 .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; \ } DEF_SAT_U_TRUC_FMT_3 (uint32_t, uint64_t) The below test is passed for this patch. * The rv64gcv regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat_u_trunc-13.c: New test. * gcc.target/riscv/sat_u_trunc-14.c: New test. * gcc.target/riscv/sat_u_trunc-15.c: New test. * gcc.target/riscv/sat_u_trunc-run-13.c: New test. * gcc.target/riscv/sat_u_trunc-run-14.c: New test. * gcc.target/riscv/sat_u_trunc-run-15.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.target/riscv/sat_arith.h | 12 +++++++++++ .../gcc.target/riscv/sat_u_trunc-13.c | 17 ++++++++++++++++ .../gcc.target/riscv/sat_u_trunc-14.c | 20 +++++++++++++++++++ .../gcc.target/riscv/sat_u_trunc-15.c | 19 ++++++++++++++++++ .../gcc.target/riscv/sat_u_trunc-run-13.c | 16 +++++++++++++++ .../gcc.target/riscv/sat_u_trunc-run-14.c | 16 +++++++++++++++ .../gcc.target/riscv/sat_u_trunc-run-15.c | 16 +++++++++++++++ 7 files changed, 116 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index 576a4926d1f..cf055410fd1 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -236,10 +236,22 @@ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \ } #define DEF_SAT_U_TRUC_FMT_2_WRAP(NT, WT) DEF_SAT_U_TRUC_FMT_2(NT, WT) +#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; \ +} +#define DEF_SAT_U_TRUC_FMT_3_WRAP(NT, WT) DEF_SAT_U_TRUC_FMT_3(NT, WT) + #define RUN_SAT_U_TRUC_FMT_1(NT, WT, x) sat_u_truc_##WT##_to_##NT##_fmt_1 (x) #define RUN_SAT_U_TRUC_FMT_1_WRAP(NT, WT, x) RUN_SAT_U_TRUC_FMT_1(NT, WT, x) #define RUN_SAT_U_TRUC_FMT_2(NT, WT, x) sat_u_truc_##WT##_to_##NT##_fmt_2 (x) #define RUN_SAT_U_TRUC_FMT_2_WRAP(NT, WT, x) RUN_SAT_U_TRUC_FMT_2(NT, WT, x) +#define RUN_SAT_U_TRUC_FMT_3(NT, WT, x) sat_u_truc_##WT##_to_##NT##_fmt_3 (x) +#define RUN_SAT_U_TRUC_FMT_3_WRAP(NT, WT, x) RUN_SAT_U_TRUC_FMT_3(NT, WT, x) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.c new file mode 100644 index 00000000000..58910793a80 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-13.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_truc_uint16_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_TRUC_FMT_3(uint8_t, uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.c new file mode 100644 index 00000000000..236ea1d45f7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-14.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_truc_uint32_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_TRUC_FMT_3(uint16_t, uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c new file mode 100644 index 00000000000..33c3686c053 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-15.c @@ -0,0 +1,19 @@ +/* { 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_truc_uint64_t_to_uint32_t_fmt_3: +** li\s+[atx][0-9]+,\s*-1 +** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32 +** 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]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_TRUC_FMT_3(uint32_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-13.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.c new file mode 100644 index 00000000000..6322305c5ed --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-13.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 uint16_t + +DEF_SAT_U_TRUC_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_TRUC_FMT_3_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.c new file mode 100644 index 00000000000..a29e887aeeb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-14.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 uint32_t + +DEF_SAT_U_TRUC_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_TRUC_FMT_3_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.c new file mode 100644 index 00000000000..a29e887aeeb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-15.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 uint32_t + +DEF_SAT_U_TRUC_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_TRUC_FMT_3_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h"