From patchwork Mon Nov 4 10:49:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 2006153 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=IC5mvuVA; 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 4XhpHq186Yz1xxN for ; Mon, 4 Nov 2024 21:54:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54B413857BAF for ; Mon, 4 Nov 2024 10:54:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by sourceware.org (Postfix) with ESMTPS id 742903857B96 for ; Mon, 4 Nov 2024 10:51:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 742903857B96 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 742903857B96 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717495; cv=none; b=HwzTEdVtpQzMQUQZzGbguoy9GbFe/EtmZOnBzINQhLMeLH7E4trVc0GJxW+r5Fl53arJom/alrhZWzU8cHx1AkA6nUIZvkYax+W9cQZ5bNmZPDLmR1VwOYyRWNGuPvhcPlRks27Gz6SkUfaYmAEAhDSKAtIVBSxXG3CFxo+uHGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717495; c=relaxed/simple; bh=mxKK4XI//ORWjTB7VNoazzASF37QFtV2B9fR/sey8MU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hp7KhtWchDKRGSNoqjqrB7Nkx7S6TQnJn3SvDsoHkEHRZBYGukvWZOiDlJHOJTPQ1sDj5jK4qQu8tQ5+IJopx0Xx2IHE5h5BBskVH8GGt+9Uup2kWfynek+13Y/9a06ihGi0rge/iStH9g4De82XJoSwBdNgZVMFKzslFVZQHx0= 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=1730717488; x=1762253488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mxKK4XI//ORWjTB7VNoazzASF37QFtV2B9fR/sey8MU=; b=IC5mvuVA7Be0u7DlitHbNTOsq1cLd3fA7U/fbQpFSPvBQ9aa9gRE0nRD fjIk/VHY8XjFyS+vbobgzM8jyOyuN4D/0VEsjqc5eofE9+itHoDinYXJz I6OKrnRPNtmmsovW8gyF5jVNKZNJaKOlSfFOKaj48qnHriWcOd0Pj4TGT AA74hjucvDXUUrTKaXKIcUf1WHPCazLa/cZJVLeMBxgK00WossSmOi6Io 2RrK04SPd5mLzoMRHhDzj//eC+DHRW9zeub+ifo5cPiCSz+kU5l24yfYC v5pBmqjV6bFyyfyRaJBaw4SIl3N411bV3lpjQfL2ahrB99l+wiU//TYZP g==; X-CSE-ConnectionGUID: Ym44PD7cQhypfxH6CsuZng== X-CSE-MsgGUID: ib1Jg2LOThuwZ3G2ICZG3g== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30510250" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30510250" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:51:27 -0800 X-CSE-ConnectionGUID: CAVqBpB+QZeTYMo/SzOhpA== X-CSE-MsgGUID: f/xcmSI9RrOYDn0aXPSqWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83732561" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 02:51:24 -0800 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, Tamar.Christina@arm.com, juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1 2/5] Test: Add testcases for form 9 of unsigned integer SAT_ADD simplify Date: Mon, 4 Nov 2024 18:49:21 +0800 Message-ID: <20241104104924.1743778-2-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104104924.1743778-1-pan2.li@intel.com> References: <20241104104924.1743778-1-pan2.li@intel.com> MIME-Version: 1.0 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 The phiopt2 pass will also try the gimple_simplify for the form 9 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-9-u16.c: New test. * gcc.dg/sat_u_add-simplify-9-u32.c: New test. * gcc.dg/sat_u_add-simplify-9-u64.c: New test. * gcc.dg/sat_u_add-simplify-9-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 7 +++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c | 11 +++++++++++ 5 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 3d4ec184452..91691c167a0 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -61,4 +61,11 @@ T sat_u_add_##T##_8 (T x, T y) \ return x + y; \ } +#define DEF_SAT_U_ADD_9(T) \ +T sat_u_add_##T##_9 (T x, T y) \ +{ \ + T ret; \ + return __builtin_add_overflow (x, y, &ret) == 0 ? ret : - 1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c new file mode 100644 index 00000000000..9e93dde6e3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_9 (uint16_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c new file mode 100644 index 00000000000..4dc760ac78c --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_9 (uint32_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c new file mode 100644 index 00000000000..8748e03e1f5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_9 (uint64_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c new file mode 100644 index 00000000000..5cffc43e081 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_9 (uint8_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */