From patchwork Thu Oct 31 06:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99884 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D51303857724 for ; Thu, 31 Oct 2024 06:30:26 +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.16]) by sourceware.org (Postfix) with ESMTPS id 21D4F3858D33 for ; Thu, 31 Oct 2024 06:29:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21D4F3858D33 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 21D4F3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356181; cv=none; b=AZAPScWHioXmVAlWQLfwot8PEx0osbky/+OSwtutY2llu8OYnjaXM7hNHhrdV0v0BnYD72XoxsgWu4ERALkVT+/rNtzYns4XTNLL3WtCiGazBIORYpLQRjFqlxwoxmJNAfyb2eIM/9SUK+QamUuYozJTYf2VxtmrKO699KZHT7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356181; c=relaxed/simple; bh=b8axbXlXIOUiT2HRa3Yy2bBak41bd0mH8RgHYTMtd9c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MntEcnsbAfc1JQVHTb8YD8LOMSl7Kpzba/wOTDr+P6kHcgD+7S6UURpYX+S/eCwlLzQhOlbRdZ7Q1TzPTas5RINlfjzj8WCagcRyWWPo51esQPOfcYOSBUNAB5ANDyn42WrN7n3k913M8KdYXyorjQ1aVBgfTwgci5pr+Ej+ufY= 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=1730356179; x=1761892179; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=b8axbXlXIOUiT2HRa3Yy2bBak41bd0mH8RgHYTMtd9c=; b=mcda87jPoof70XAj/ROduy/HEosGCyQffwCPWiNaDw6tSc5AfkHEDmr1 4RjnrJx2v28nQySCCRJGKB4POUaDHqWXRdAZrKkXRFKyz2tilM/ediTAd P/4InneGZpCYxRJarW5P2OwEvz7ZeihOsLiQ8ZVxrAIbHPYrmThm+glfT l6vmVm98HPelWzSJgYJvFdMSEAOw4mMp4+zvr4lm12GGnnivHDbQuXPT3 Dstp4j35i7cY9NuqEXXBOJfXbU5Urj8eU7tmxxoPIrLm4kjU/Br8X8S3d zwjSPSytWifE38OEaiLBCaqpTC8f64IobQfYL9YDyVPlIC1LYXo5pxztX Q==; X-CSE-ConnectionGUID: cMQsuv+uQ8yUg9nNi3Razw== X-CSE-MsgGUID: 1XF2+yFhRByMwSNyhfhssA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238413" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238413" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:38 -0700 X-CSE-ConnectionGUID: fsM/5qk2RwGHL5uoySMagQ== X-CSE-MsgGUID: v6X2UL9xS/+If3Tudk9uAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82454999" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:35 -0700 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 v2 01/10] Match: Simplify branch form 4 of unsigned SAT_ADD into branchless Date: Thu, 31 Oct 2024 14:27:33 +0800 Message-ID: <20241031062742.2709845-1-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li There are sorts of forms for the unsigned SAT_ADD. Some of them are complicated while others are cheap. This patch would like to simplify the complicated form into the cheap ones. For example as below: From the form 4 (branch): SAT_U_ADD = (X + Y) < x ? -1 : (X + Y). To (branchless): SAT_U_ADD = (X + Y) | - ((X + Y) < X). #define T uint8_t T sat_add_u_1 (T x, T y) { return (T)(x + y) < x ? -1 : (x + y); } Before this patch: 1 │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y) 2 │ { 3 │ uint8_t D.2809; 4 │ 5 │ _1 = x + y; 6 │ if (x <= _1) goto ; else goto ; 7 │ : 8 │ D.2809 = x + y; 9 │ goto ; 10 │ : 11 │ D.2809 = 255; 12 │ : 13 │ return D.2809; 14 │ } After this patch: 1 │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y) 2 │ { 3 │ uint8_t D.2809; 4 │ 5 │ _1 = x + y; 6 │ _2 = x + y; 7 │ _3 = x > _2; 8 │ _4 = (unsigned char) _3; 9 │ _5 = -_4; 10 │ D.2809 = _1 | _5; 11 │ return D.2809; 12 │ } The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Remove unsigned branch form 4 for SAT_ADD, and add simplify to branchless instead. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: New test. * gcc.dg/sat_u_add-simplify-2-u16.c: New test. * gcc.dg/sat_u_add-simplify-2-u32.c: New test. * gcc.dg/sat_u_add-simplify-2-u64.c: New test. * gcc.dg/sat_u_add-simplify-2-u8.c: New test. Signed-off-by: Pan Li --- gcc/match.pd | 23 +++++++++---------- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 10 ++++++++ .../gcc.dg/sat_u_add-simplify-2-u16.c | 11 +++++++++ .../gcc.dg/sat_u_add-simplify-2-u32.c | 11 +++++++++ .../gcc.dg/sat_u_add-simplify-2-u64.c | 11 +++++++++ .../gcc.dg/sat_u_add-simplify-2-u8.c | 11 +++++++++ 6 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/sat_arith_simplify.h create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u8.c diff --git a/gcc/match.pd b/gcc/match.pd index c851ac56e37..8425d7c4f20 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3146,18 +3146,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (match (unsigned_integer_sat_add @0 @1) (bit_ior:c (usadd_left_part_2 @0 @1) (usadd_right_part_2 @0 @1))) -/* Simplify SAT_U_ADD to the cheap form - From: SAT_U_ADD = (X + Y) >= x ? (X + Y) : -1. - To: SAT_U_ADD = (X + Y) | - ((X + Y) < X). */ -(simplify (cond (ge (plus:c@2 @0 @1) @0) @2 integer_minus_onep) - (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) - && types_match (type, @0, @1)) - (bit_ior @2 (negate (convert (lt @2 @0)))))) - -/* Unsigned saturation add, case 4 (branch with lt): - SAT_U_ADD = (X + Y) < x ? -1 : (X + Y). */ -(match (unsigned_integer_sat_add @0 @1) - (cond^ (lt (usadd_left_part_1@2 @0 @1) @0) integer_minus_onep @2)) +/* Simplify sorts of SAT_U_ADD forms to the cheap one. + The cheap form: SAT_U_ADD = (X + Y) | - ((X + Y) < X). */ +(if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)) + /* From SAT_U_ADD = (X + Y) >= x ? (X + Y) : -1. */ + (simplify (cond (ge (plus:c@2 @0 @1) @0) @2 integer_minus_onep) + (if (types_match (type, @0, @1)) + (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0)))))) + /* From SAT_U_ADD = (X + Y) < x ? -1 : (X + Y). */ + (simplify (cond (lt (plus:c@2 @0 @1) @0) integer_minus_onep @2) + (if (types_match (type, @0, @1)) + (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0))))))) /* Unsigned saturation add, case 5 (branch with eq .ADD_OVERFLOW): SAT_U_ADD = REALPART_EXPR <.ADD_OVERFLOW> == 0 ? .ADD_OVERFLOW : -1. */ diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h new file mode 100644 index 00000000000..46ac00426b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -0,0 +1,10 @@ +#ifndef HAVE_DEFINED_SAT_ARITH_SIMPLIFY_H +#define HAVE_DEFINED_SAT_ARITH_SIMPLIFY_H + +#define DEF_SAT_U_ADD_2(T) \ +T sat_u_add_##T##_2 (T x, T y) \ +{ \ + return (T)(x + y) < x ? -1 : (x + y); \ +} + +#endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u16.c new file mode 100644 index 00000000000..b170b35096c --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u16.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_2 (uint16_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u32.c new file mode 100644 index 00000000000..8830ed7b878 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u32.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_2 (uint32_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u64.c new file mode 100644 index 00000000000..76c4d4bddaa --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u64.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_2 (uint64_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u8.c new file mode 100644 index 00000000000..b034b8eedb1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-2-u8.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_2 (uint8_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ From patchwork Thu Oct 31 06:27:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99885 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 152383857836 for ; Thu, 31 Oct 2024 06:30:32 +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.16]) by sourceware.org (Postfix) with ESMTPS id 2B89B3858D39 for ; Thu, 31 Oct 2024 06:29:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B89B3858D39 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 2B89B3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356184; cv=none; b=p4a599YJj7xAgissn2hIyaw4h7W88OE1pDg0FTKWvfH6Ku0Ewnb5e90pdF3iJiY7lb21aJv7rEwTYqoA2rzImU2ZwjEbdBTxKJEERGxNR8Z+UzzQpnVTWfMOT3lPlpnqAFWPKoZQ2Bkis8gLr4gPfIXXpICgKUPwwZrjFDrU4Zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356184; c=relaxed/simple; bh=ih62RWuBh0XuAV/CvMmTI1v1v5aq/uW8xmUU6d81Vqc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BgDzPnxVo88+tDkBL5EeYKhakIIEmiwHUaWQgTdThWuMO4ji/wr2utA316M9LEgO964Oql+rT1xPlcK6XGADN7bhiQ/kn5RAz0A04Dr3SkvK/7TYx6pn/IUJYeXtIrQcCzMUbF6IkhahBv5ElEL2XX9nSEftXKUGfq/iJ9mNavk= 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=1730356181; x=1761892181; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ih62RWuBh0XuAV/CvMmTI1v1v5aq/uW8xmUU6d81Vqc=; b=baqXeYS6XUE26z/IcRLzqPXQzchWoT4UEqWCznrsgvQhr8NJ26xiBS1e 4tJEZ2v7zqHPoMY1XgcTk8wjMHfUXaDfIZP0Ym2nxA/c8m9Nfro+C5Ml6 uYAiybonNphtny2tlN624EcNcCxn8Nr00SBTpyy5lT8lxTodbreWp3O8i LLDu+iaAZDt+Nsuyw+O3PnLlPkLxXayE0hLJc78ZoDxcHGQ2b7gon3PR7 laZsUDNZHoXGbJs5c1lULYb7FyY3lRb53e1XtkvHS3N3Zg0aRbTTDb6xa LyIzwvAPn5qTS4dOzk8I3ESRBqcYqrYfdz1WZDCFNO8SLNg44sSg7loIa g==; X-CSE-ConnectionGUID: JxpdQNFgRYu1EyIp7vcKZg== X-CSE-MsgGUID: C+wYmJ6KQZei9rPFRqGldA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238421" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238421" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:40 -0700 X-CSE-ConnectionGUID: X99isVlWQf+L8WN8VfQCIg== X-CSE-MsgGUID: 39n8U3zIQYeOSKTa+akqmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455008" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:38 -0700 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 v2 02/10] Match: Simplify branch form 7 of unsigned SAT_ADD into branchless Date: Thu, 31 Oct 2024 14:27:34 +0800 Message-ID: <20241031062742.2709845-2-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li There are sorts of forms for the unsigned SAT_ADD. Some of them are complicated while others are cheap. This patch would like to simplify the complicated form into the cheap ones. For example as below: From the form 7 (branch): SAT_U_ADD = x <= (T)(x + y) ? (x + y) : -1. To (branchless): SAT_U_ADD = (X + Y) | - ((X + Y) < X). #define T uint8_t T sat_add_u_1 (T x, T y) { return x <= (T)(x + y) ? (x + y) : -1; } Before this patch: 1 │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y) 2 │ { 3 │ uint8_t D.2809; 4 │ 5 │ _1 = x + y; 6 │ if (x <= _1) goto ; else goto ; 7 │ : 8 │ D.2809 = x + y; 9 │ goto ; 10 │ : 11 │ D.2809 = 255; 12 │ : 13 │ return D.2809; 14 │ } After this patch: 1 │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y) 2 │ { 3 │ uint8_t D.2809; 4 │ 5 │ _1 = x + y; 6 │ _2 = x + y; 7 │ _3 = x > _2; 8 │ _4 = (unsigned char) _3; 9 │ _5 = -_4; 10 │ D.2809 = _1 | _5; 11 │ return D.2809; 12 │ } The simplify doesn't need to check if target support the SAT_ADD, it is somehow the optimization in gimple level. The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Remove unsigned branch form 7 for SAT_ADD, and add simplify to branchless instead. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-3-u16.c: New test. * gcc.dg/sat_u_add-simplify-3-u32.c: New test. * gcc.dg/sat_u_add-simplify-3-u64.c: New test. * gcc.dg/sat_u_add-simplify-3-u8.c: New test. Signed-off-by: Pan Li --- gcc/match.pd | 9 ++++----- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 6 ++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u8.c | 11 +++++++++++ 6 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u8.c diff --git a/gcc/match.pd b/gcc/match.pd index 8425d7c4f20..5bfba46b0ce 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3153,6 +3153,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (cond (ge (plus:c@2 @0 @1) @0) @2 integer_minus_onep) (if (types_match (type, @0, @1)) (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0)))))) + /* From SAT_ADD = x <= (X + Y) ? (X + Y) : -1. */ + (simplify (cond (le @0 (plus:c@2 @0 @1)) @2 integer_minus_onep) + (if (types_match (type, @0, @1)) + (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0)))))) /* From SAT_U_ADD = (X + Y) < x ? -1 : (X + Y). */ (simplify (cond (lt (plus:c@2 @0 @1) @0) integer_minus_onep @2) (if (types_match (type, @0, @1)) @@ -3170,11 +3174,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond^ (ne (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop) integer_minus_onep (usadd_left_part_2 @0 @1))) -/* Unsigned saturation add, case 7 (branch with le): - SAT_ADD = x <= (X + Y) ? (X + Y) : -1. */ -(match (unsigned_integer_sat_add @0 @1) - (cond^ (le @0 (usadd_left_part_1@2 @0 @1)) @2 integer_minus_onep)) - /* Unsigned saturation add, case 8 (branch with gt): SAT_ADD = x > (X + Y) ? -1 : (X + Y). */ (match (unsigned_integer_sat_add @0 @1) diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 46ac00426b2..a630936108f 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -7,4 +7,10 @@ T sat_u_add_##T##_2 (T x, T y) \ return (T)(x + y) < x ? -1 : (x + y); \ } +#define DEF_SAT_U_ADD_3(T) \ +T sat_u_add_##T##_3 (T x, T y) \ +{ \ + return x <= (T)(x + y) ? (x + y) : -1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u16.c new file mode 100644 index 00000000000..6998ce0999d --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u16.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_3 (uint16_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u32.c new file mode 100644 index 00000000000..6ee61ef7102 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u32.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_3 (uint32_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u64.c new file mode 100644 index 00000000000..e444b93c70c --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u64.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_3 (uint64_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u8.c new file mode 100644 index 00000000000..3f114d77b75 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-3-u8.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_3 (uint8_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ From patchwork Thu Oct 31 06:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99889 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A0D43857727 for ; Thu, 31 Oct 2024 06:31:39 +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.16]) by sourceware.org (Postfix) with ESMTPS id 356A23858D3C for ; Thu, 31 Oct 2024 06:29:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 356A23858D3C 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 356A23858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356189; cv=none; b=Ct8809mX2rlqOYkB03kk1wSbDj5KrauBRTb3a+zO/sO2+vmUBUY37QnxgZHoeOup4OWiW7Ny/iGCnOModPZ70Gdau0ZOWfqXGw45vzJ32E6sWArkJcnttdtFv2ouYx5dJ4OWx/mv3SeZUAPgejeWAqCJA6AimdUH+xuONttvoQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356189; c=relaxed/simple; bh=yxk5ZUe1CCgtraS2UOhOKRUUECj/eC6ekLJhUEaR7jA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bTe85EIOaYkAnoFs7t5qBQ6MmiYdOu2ju4NJP/iDeq0VAMPdFdHsbaeSx7qhl5r0PWKu/5nCE1iCSect7Wxf6cMNE0neWVpz52A8OveT2yAWBwhahkku89SxCTqVjrtbZdeOPQfFcn/qcRTw3im3TT+DDH2oc5c2oH+kmk0Wc5E= 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=1730356183; x=1761892183; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yxk5ZUe1CCgtraS2UOhOKRUUECj/eC6ekLJhUEaR7jA=; b=TObwxNk7i2DvAatM8hJ4cNMV33wthId1A8VdOUfcPIEBpfpmEzUUTLOA OxuJpwzyPAYsLXNvQrUJLUgCrL5OfvCCYgmvkWd7FeQuwG899GrTLje7u twzPYUn7882lDeilRXr6NUBLEBF+Q01xzxPIvOHm+WodjufVEGZGeUSzp vsf/x/ZBn7RdHDrBZO2MhSqLQhD5pEFMzRgrHAfbws/qYsppWTmi1N7KG t63wWN2n6pdsjY0aWU6YaLqKDjKF0HX0IgSU3j3KSdxRr3y2fHlGGkG5c Vou8VGSnIOm2OKwZ1WO01trNc5OfZvgJqp9uC23Roc04f+zdWfAH6VEmv g==; X-CSE-ConnectionGUID: Qv9XUv2EQwWSp0Ys1qRTZw== X-CSE-MsgGUID: I77crlsQS56wdE+b3erhUg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238427" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238427" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:43 -0700 X-CSE-ConnectionGUID: aHr5KEOMRA6eHPSJ+vaoFQ== X-CSE-MsgGUID: AyqZ/enUT6uJqPaqjxovJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455021" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:40 -0700 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 v2 03/10] Match: Simplify branch form 8 of unsigned SAT_ADD into branchless Date: Thu, 31 Oct 2024 14:27:35 +0800 Message-ID: <20241031062742.2709845-3-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li There are sorts of forms for the unsigned SAT_ADD. Some of them are complicated while others are cheap. This patch would like to simplify the complicated form into the cheap ones. For example as below: From the form 8 (branch): SAT_U_ADD = x > (T)(x + y) ? -1 : (x + y). To (branchless): SAT_U_ADD = (X + Y) | - ((X + Y) < X). #define T uint8_t T sat_add_u_1 (T x, T y) { return x > (T)(x + y) ? -1 : (x + y); } Before this patch: 1 │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y) 2 │ { 3 │ uint8_t D.2809; 4 │ 5 │ _1 = x + y; 6 │ if (x <= _1) goto ; else goto ; 7 │ : 8 │ D.2809 = x + y; 9 │ goto ; 10 │ : 11 │ D.2809 = 255; 12 │ : 13 │ return D.2809; 14 │ } After this patch: 1 │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y) 2 │ { 3 │ uint8_t D.2809; 4 │ 5 │ _1 = x + y; 6 │ _2 = x + y; 7 │ _3 = x > _2; 8 │ _4 = (unsigned char) _3; 9 │ _5 = -_4; 10 │ D.2809 = _1 | _5; 11 │ return D.2809; 12 │ } The simplify doesn't need to check if target support the SAT_ADD, it is somehow the optimization in gimple level. The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Remove unsigned branch form 8 for SAT_ADD, and add simplify to branchless instead. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-4-u16.c: New test. * gcc.dg/sat_u_add-simplify-4-u32.c: New test. * gcc.dg/sat_u_add-simplify-4-u64.c: New test. * gcc.dg/sat_u_add-simplify-4-u8.c: New test. Signed-off-by: Pan Li --- gcc/match.pd | 9 ++++----- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 6 ++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u8.c | 11 +++++++++++ 6 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u8.c diff --git a/gcc/match.pd b/gcc/match.pd index 5bfba46b0ce..2390e96672e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3157,6 +3157,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (cond (le @0 (plus:c@2 @0 @1)) @2 integer_minus_onep) (if (types_match (type, @0, @1)) (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0)))))) + /* From SAT_ADD = x > (X + Y) ? -1 : (X + Y). */ + (simplify (cond (gt @0 (plus:c@2 @0 @1)) integer_minus_onep @2) + (if (types_match (type, @0, @1)) + (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0)))))) /* From SAT_U_ADD = (X + Y) < x ? -1 : (X + Y). */ (simplify (cond (lt (plus:c@2 @0 @1) @0) integer_minus_onep @2) (if (types_match (type, @0, @1)) @@ -3174,11 +3178,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond^ (ne (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop) integer_minus_onep (usadd_left_part_2 @0 @1))) -/* Unsigned saturation add, case 8 (branch with gt): - SAT_ADD = x > (X + Y) ? -1 : (X + Y). */ -(match (unsigned_integer_sat_add @0 @1) - (cond^ (gt @0 (usadd_left_part_1@2 @0 @1)) integer_minus_onep @2)) - /* Unsigned saturation add, case 9 (one op is imm): SAT_U_ADD = (X + 3) >= x ? (X + 3) : -1. */ (match (unsigned_integer_sat_add @0 @1) diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index a630936108f..89577ffabb1 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -13,4 +13,10 @@ T sat_u_add_##T##_3 (T x, T y) \ return x <= (T)(x + y) ? (x + y) : -1; \ } +#define DEF_SAT_U_ADD_4(T) \ +T sat_u_add_##T##_4 (T x, T y) \ +{ \ + return x > (T)(x + y) ? -1 : (x + y); \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u16.c new file mode 100644 index 00000000000..841ff5a22bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u16.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_4 (uint16_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u32.c new file mode 100644 index 00000000000..6b305671fd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u32.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_4 (uint32_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u64.c new file mode 100644 index 00000000000..0aac0fddab1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u64.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_4 (uint64_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u8.c new file mode 100644 index 00000000000..03bfdf6b34f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-4-u8.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_4 (uint8_t) + +/* { dg-final { scan-tree-dump-not " if " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " else " "gimple" } } */ +/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */ From patchwork Thu Oct 31 06:27:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99886 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 539493857BB9 for ; Thu, 31 Oct 2024 06:30:40 +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.16]) by sourceware.org (Postfix) with ESMTPS id 874BB385843B for ; Thu, 31 Oct 2024 06:29:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 874BB385843B 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 874BB385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356190; cv=none; b=Q9bDujY1I2syt+w1ECsijunnvfatrYX1yKT47M0JFvER1dcSY5aeW5eIj3s9mx3l6DdrnUKXQaGTJMJ2TWw8nI8k6ZkN1L4GBai09QPqITgOzI8mBtWIYfx5TDzoBqydu8iJf0Pcl2Z8uyZPjlZtyBuKvuxSjQQL0zWapGW6I7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356190; c=relaxed/simple; bh=UPFdnLWP6shZinepS3JtCLoOj5MWTyaBeLnVBWIXvcI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MyO02Qwm9vSrOMO5bzVw7c30cOSs9VxW2Orifo45r0hK5CsmUusxW7bAuPShXdG8NiXfJsJ52gwUrWHESBID7CQY7PFIspHChZC7bq8Vkv7K4FLP+4btOhstHJFRQJuwC6mmZwJ1ADKZ0au5OF5bwkE5saUP8mtnSTD2OC9M4ls= 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=1730356186; x=1761892186; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UPFdnLWP6shZinepS3JtCLoOj5MWTyaBeLnVBWIXvcI=; b=b2tpg8JyJGIDOyVcFracDTQ9Ps4rD6kOOXXREwaN1VpEVBsMRsP4ZrBc 0VC/C0TnPz3mD1nCW2mw3ywJpZdhi/vYXJq/WpZsMA5XBpw1xdx5AjmRX /dVtw8WnW1Tqm9jNGB+i73q2wKqv6qUIHka4v2pVOWBaa5n4gD3C2SW8r yBAivIvP6MWEofNTL3JjjTZEKKnnVnz8FQzGq/3wtLUS7btnkTM3aRe8Y rkvsAxQTDWP/aW3ghvDerVbIYCAQ4an5LtJPICq+NjHxWY0W1JbgXe6bq Jzi7vPSdweZ7dloFJWfy9++fkUTC7u0p33CIFWXHo8qLUItHeBsw85WCP A==; X-CSE-ConnectionGUID: ZGso4FGzQbSfmz3pSRjSzQ== X-CSE-MsgGUID: G8g/PlkKQOypo+lz9wfs3w== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238435" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238435" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:45 -0700 X-CSE-ConnectionGUID: auM7/04DS3OQRq1FTPsyFw== X-CSE-MsgGUID: KLHN5JT1Q02Q1/Rd82FLpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455034" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:43 -0700 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 v2 04/10] Match: Remove usadd_left_part_1 as it has only one reference [NFC] Date: Thu, 31 Oct 2024 14:27:36 +0800 Message-ID: <20241031062742.2709845-4-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li In previous, we extract matching usadd_left_part_1 to avoid duplication. After we simplify some usadd patterns into cheap form, there will be only one reference to this matching. Thus, remove this matching pattern and unfold it to the reference place. 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/ChangeLog: * match.pd: Remove matching usadd_left_part_1 and unfold it at its reference place Signed-off-by: Pan Li --- gcc/match.pd | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 2390e96672e..94e9f094631 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3086,14 +3086,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) || POINTER_TYPE_P (itype)) && wi::eq_p (wi::to_wide (int_cst), wi::max_value (itype)))))) -/* Unsigned Saturation Add */ -/* SAT_ADD = usadd_left_part_1 | usadd_right_part_1, aka: - SAT_ADD = (X + Y) | -((X + Y) < X) */ -(match (usadd_left_part_1 @0 @1) - (plus:c @0 @1) - (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) - && types_match (type, @0, @1)))) - /* SAT_ADD = usadd_left_part_2 | usadd_right_part_2, aka: SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | (IMAGPART_EXPR <.ADD_OVERFLOW> != 0) */ (match (usadd_left_part_2 @0 @1) @@ -3101,7 +3093,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) -/* SAT_ADD = usadd_left_part_1 | usadd_right_part_1, aka: +/* SAT_ADD = (X + Y) | usadd_right_part_1, aka: SAT_ADD = (X + Y) | -((type)(X + Y) < X) */ (match (usadd_right_part_1 @0 @1) (negate (convert (lt (plus:c @0 @1) @0))) @@ -3129,7 +3121,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) -/* We cannot merge or overload usadd_left_part_1 and usadd_left_part_2 +/* We cannot merge or overload (X + Y) and usadd_left_part_2 because the sub part of left_part_2 cannot work with right_part_1. For example, left_part_2 pattern focus one .ADD_OVERFLOW but the right_part_1 has nothing to do with .ADD_OVERFLOW. */ @@ -3138,7 +3130,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) SAT_U_ADD = (X + Y) | - ((X + Y) < X) or SAT_U_ADD = (X + Y) | - (X > (X + Y)). */ (match (unsigned_integer_sat_add @0 @1) - (bit_ior:c (usadd_left_part_1 @0 @1) (usadd_right_part_1 @0 @1))) + (bit_ior:c (plus:c @0 @1) (usadd_right_part_1 @0 @1))) /* Unsigned saturation add, case 2 (branchless with .ADD_OVERFLOW): SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | -IMAGPART_EXPR <.ADD_OVERFLOW> or From patchwork Thu Oct 31 06:27:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99887 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AEC6E3857723 for ; Thu, 31 Oct 2024 06:30:44 +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.16]) by sourceware.org (Postfix) with ESMTPS id 296433857836 for ; Thu, 31 Oct 2024 06:29:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 296433857836 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 296433857836 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356191; cv=none; b=VLQBZroWn+clQ/OD0jkoTrZBckMUeph2LO8n0JfXlvUtTpJmVyYkBZJWqh2Np7FqU64iT8uw0FxDVqZe2Mz9fUvDsQ+ApVgd961IY2e2g1AlP39X/FMdmpTuJTChA+r2DepOld82IpskOw6A/KPG/6xT+CKxLXjP24o4o6JuASo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356191; c=relaxed/simple; bh=Y8dy+YvLblUpQ9OfR1XYIBFInWj8st+3Oju/BLYgbuA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EzQC7WDgaHwggelDvHKg5DQAQe03U+ACUXzkiDSlDIGC74g8zj3oGo7QFXLFiAk3zqqpXF0821tnAuDun3ZjHAQJRFioVnP7aWS/r8nTWX5jTaPWSlM2tEf27DndzFSGMk18lJKqAqAEvXgRoCBZHQTN7SojPiw1OATOJDnS96g= 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=1730356189; x=1761892189; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y8dy+YvLblUpQ9OfR1XYIBFInWj8st+3Oju/BLYgbuA=; b=MUCz+Rnn6/ihQ07z7sqwWfsPx/+uO075A/xMu4hunck2a4fsXt0p2Zrw fxfvn9FQWXERLKQduRoOlsl8hIl7yQYP5WaMt4hwloS078SR9bHuHnwjH fEFq3dwFScAsN8cQOfmCkfK0A79KUYpLhtEDAkBJw/UAmVHtm/VUbSFuv /DV0pZMe7bc8MA5vOALlTMq+BWyO4zg+rrUokXQvrshTS2tlbLFE2Vzjg vDyVzrNF4rO+5z34oYyH7eQ5WTTgZjh5PuEZJYQHGBcZYtyKEGnMZmERp O1XA9ye9IUNUPuXpDm3i8NhZ/baVN1f7p4RaU4M06yuE5VJOCiSPU/QfT g==; X-CSE-ConnectionGUID: DNz2CmgESP6tMAJ+dVEl5w== X-CSE-MsgGUID: pBQ6C32mRTClzr47cBa7RA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238441" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238441" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:48 -0700 X-CSE-ConnectionGUID: pZEpp77HQEmY1Nj36bvHlg== X-CSE-MsgGUID: 9BTTT7ssTGyiHkpSR8VT3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455047" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:45 -0700 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 v2 05/10] Match: Update the comments of unsigned integer SAT_ADD [NFC] Date: Thu, 31 Oct 2024 14:27:37 +0800 Message-ID: <20241031062742.2709845-5-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li Sorts of comments of unsigned integer SAT_ADD matching is not updated to date. This patch would like to refine it. 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/ChangeLog: * match.pd: Update the comments of unsigned integer SAT_ADD. Signed-off-by: Pan Li --- gcc/match.pd | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 94e9f094631..f6f55491b89 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3086,36 +3086,39 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) || POINTER_TYPE_P (itype)) && wi::eq_p (wi::to_wide (int_cst), wi::max_value (itype)))))) -/* SAT_ADD = usadd_left_part_2 | usadd_right_part_2, aka: - SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | (IMAGPART_EXPR <.ADD_OVERFLOW> != 0) */ +/* SAT_U_ADD = usadd_left_part_2 | usadd_right_part_2, aka: + SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = REALPART_EXPR (SUM) | (IMAGPART_EXPR (SUM) != 0) */ (match (usadd_left_part_2 @0 @1) (realpart (IFN_ADD_OVERFLOW:c @0 @1)) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) -/* SAT_ADD = (X + Y) | usadd_right_part_1, aka: - SAT_ADD = (X + Y) | -((type)(X + Y) < X) */ +/* SAT_U_ADD = (X + Y) | usadd_right_part_1, aka: + SAT_U_ADD = (X + Y) | -((type)(X + Y) < X) */ (match (usadd_right_part_1 @0 @1) (negate (convert (lt (plus:c @0 @1) @0))) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) -/* SAT_ADD = usadd_left_part_1 | usadd_right_part_1, aka: - SAT_ADD = (X + Y) | -(X > (X + Y)) */ +/* SAT_U_ADD = usadd_left_part_1 | usadd_right_part_1, aka: + SAT_U_ADD = (X + Y) | -(X > (X + Y)) */ (match (usadd_right_part_1 @0 @1) (negate (convert (gt @0 (plus:c @0 @1)))) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) -/* SAT_ADD = usadd_left_part_2 | usadd_right_part_2, aka: - SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | (IMAGPART_EXPR <.ADD_OVERFLOW> != 0) */ +/* SAT_U_ADD = usadd_left_part_2 | usadd_right_part_2, aka: + SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = REALPART_EXPR (SUM) | (IMAGPART_EXPR (SUM) != 0) */ (match (usadd_right_part_2 @0 @1) (negate (convert (ne (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop))) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) -/* SAT_ADD = usadd_left_part_2 | usadd_right_part_2, aka: - SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | -IMAGPART_EXPR <.ADD_OVERFLOW> */ +/* SAT_U_ADD = usadd_left_part_2 | usadd_right_part_2, aka: + SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = REALPART_EXPR (SUM) | -IMAGPART_EXPR (SUM) */ (match (usadd_right_part_2 @0 @1) (negate (imagpart (IFN_ADD_OVERFLOW:c @0 @1))) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) @@ -3133,8 +3136,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_ior:c (plus:c @0 @1) (usadd_right_part_1 @0 @1))) /* Unsigned saturation add, case 2 (branchless with .ADD_OVERFLOW): - SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | -IMAGPART_EXPR <.ADD_OVERFLOW> or - SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | (IMAGPART_EXPR <.ADD_OVERFLOW> != 0) */ + SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = REALPART_EXPR (SUM) | -IMAGPART_EXPR (SUM) or + SAT_U_ADD = REALPART_EXPR (SUM) | (IMAGPART_EXPR (SUM) != 0). */ (match (unsigned_integer_sat_add @0 @1) (bit_ior:c (usadd_left_part_2 @0 @1) (usadd_right_part_2 @0 @1))) @@ -3159,13 +3163,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0))))))) /* Unsigned saturation add, case 5 (branch with eq .ADD_OVERFLOW): - SAT_U_ADD = REALPART_EXPR <.ADD_OVERFLOW> == 0 ? .ADD_OVERFLOW : -1. */ + SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = IMAGPART_EXPR (SUM) == 0 ? REALPART_EXPR (SUM) : -1. */ (match (unsigned_integer_sat_add @0 @1) (cond^ (eq (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop) (usadd_left_part_2 @0 @1) integer_minus_onep)) /* Unsigned saturation add, case 6 (branch with ne .ADD_OVERFLOW): - SAT_U_ADD = REALPART_EXPR <.ADD_OVERFLOW> != 0 ? -1 : .ADD_OVERFLOW. */ + SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = IMAGPART_EXPR (SUM) != 0 ? -1 : REALPART_EXPR (SUM). */ (match (unsigned_integer_sat_add @0 @1) (cond^ (ne (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop) integer_minus_onep (usadd_left_part_2 @0 @1))) @@ -3187,7 +3193,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (wi::eq_p (max, sum)))))) /* Unsigned saturation add, case 10 (one op is imm): - SAT_U_ADD = __builtin_add_overflow (X, 3, &ret) == 0 ? ret : -1. */ + SUM = ADD_OVERFLOW (X, IMM) + SAT_U_ADD = IMAGPART_EXPR (SUM) == 0 ? REALPART_EXPR (SUM) : -1. */ (match (unsigned_integer_sat_add @0 @1) (cond^ (ne (imagpart (IFN_ADD_OVERFLOW@2 @0 INTEGER_CST@1)) integer_zerop) integer_minus_onep (realpart @2)) From patchwork Thu Oct 31 06:27:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99890 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 288043857365 for ; Thu, 31 Oct 2024 06:31:51 +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.16]) by sourceware.org (Postfix) with ESMTPS id D2F75385783B for ; Thu, 31 Oct 2024 06:29:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2F75385783B 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 D2F75385783B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356199; cv=none; b=JWJXswzkoRzZQHIxIngyL3g3KRFPPWTh2t41QNc5ezkJuhFTq6z/0Z5lCEwQya9GWEpa/JUb0pz2mLoCILvwXc2LdFi0V9DGekimW71sC9H7L8B9wQFtvs7wrpRrB6piTwOHxYOXXn7L8kCvxjmBYPuvzw7zw2fhe13DJOgvozo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356199; c=relaxed/simple; bh=Mj8RmIbdF9Gxp32MvTUpoDtCiLivsDVZC9k99Rian2A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hyg6FOSOwh1BSe34fYue7VVyVEApzlsfGhO+ig9ljfOEiXrrGbaZZo3Q2Hd7YnznvYjX/gD4IER6XhobeNNOZaLYD7Uc2MaAChrDEZVFb0Ix+FLidO+y8Mu3DkQi3WMpsqDUPAj7mPW6E0nMnkko8yUpypvXlHKOe4iU6T6wK/Y= 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=1730356191; x=1761892191; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mj8RmIbdF9Gxp32MvTUpoDtCiLivsDVZC9k99Rian2A=; b=PuHwOYA5qEtT908d5HHrlvedhPAKvHHlj3IFgm2UzDbHIrMh1+iNQb5m 6HoWVBg4D7IKKxj1wra+iaO18TUmIn6nr2pb8t1SI1LbTH49ainEKlI9p rSU71VTwR0WmEKuRMYoWM9FyPScLmJ4JBzkGLzLrc8uBvSCeTwlz1Asr6 pHmGokmlNs72QPE3yyfYyEU7q6cMRodH/p7mPSvRN31t09wiuUIKqZloy n4JmHPutFglbZpWPxsO764xJZcDiyi+NFYzuskX0hxMOxUiZg57IvWjPa 9T2Wk5srqeEx2d82sMv/I8KuuYfsjcbYBSU5y5+NWQojE1E+mJfnRU4je A==; X-CSE-ConnectionGUID: 8jtfYoubTd61zHxq1hLm/g== X-CSE-MsgGUID: /GkuTpPZRv6lJXYWM6yiNw== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238447" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238447" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:50 -0700 X-CSE-ConnectionGUID: g4bvldzdRBWeW+domgVLPQ== X-CSE-MsgGUID: MJH+bFm/Rb6HpYTXskUgIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455055" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:48 -0700 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 v2 06/10] Test: Move unsigned integer SAT_ADD simplify testcases to gcc.dg Date: Thu, 31 Oct 2024 14:27:38 +0800 Message-ID: <20241031062742.2709845-6-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li As suggested by Richard, move the SAT_ADD simplify testcases from the tree-ssa to gcc.dg. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test macros. * gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c: Move to... * gcc.dg/sat_u_add-simplify-1-u16.c: ...here. * gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c: Move to... * gcc.dg/sat_u_add-simplify-1-u32.c: ...here. * gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c: Move to... * gcc.dg/sat_u_add-simplify-1-u64.c: ...here. * gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c: Move to... * gcc.dg/sat_u_add-simplify-1-u8.c: ...here. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 6 ++++++ .../gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u16.c | 8 ++------ .../gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u32.c | 8 ++------ .../gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u64.c | 8 ++------ .../gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u8.c | 8 ++------ 5 files changed, 14 insertions(+), 24 deletions(-) rename gcc/testsuite/gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u16.c (75%) rename gcc/testsuite/gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u32.c (75%) rename gcc/testsuite/gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u64.c (75%) rename gcc/testsuite/gcc.dg/{tree-ssa => }/sat_u_add-simplify-1-u8.c (75%) diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 89577ffabb1..1d66f6f25e3 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -1,6 +1,12 @@ #ifndef HAVE_DEFINED_SAT_ARITH_SIMPLIFY_H #define HAVE_DEFINED_SAT_ARITH_SIMPLIFY_H +#define DEF_SAT_U_ADD_1(T) \ +T sat_u_add_##T##_1 (T x, T y) \ +{ \ + return (T)(x + y) >= x ? (x + y) : -1; \ +} + #define DEF_SAT_U_ADD_2(T) \ T sat_u_add_##T##_2 (T x, T y) \ { \ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u16.c similarity index 75% rename from gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c rename to gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u16.c index 7617fbaca45..bf897f4af59 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u16.c @@ -2,13 +2,9 @@ /* { dg-options "-O2 -fdump-tree-gimple-details" } */ #include +#include "sat_arith_simplify.h" -#define T uint16_t - -T sat_add_u_1 (T x, T y) -{ - return (T)(x + y) >= x ? (x + y) : -1; -} +DEF_SAT_U_ADD_1 (uint16_t) /* { dg-final { scan-tree-dump-not " if " "gimple" } } */ /* { dg-final { scan-tree-dump-not " else " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u32.c similarity index 75% rename from gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c rename to gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u32.c index efea85bfbb7..0ba1d3e92d7 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u32.c @@ -2,13 +2,9 @@ /* { dg-options "-O2 -fdump-tree-gimple-details" } */ #include +#include "sat_arith_simplify.h" -#define T uint32_t - -T sat_add_u_1 (T x, T y) -{ - return (T)(x + y) >= x ? (x + y) : -1; -} +DEF_SAT_U_ADD_1 (uint32_t) /* { dg-final { scan-tree-dump-not " if " "gimple" } } */ /* { dg-final { scan-tree-dump-not " else " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u64.c similarity index 75% rename from gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c rename to gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u64.c index b7b55d72ede..723799dd612 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u64.c @@ -2,13 +2,9 @@ /* { dg-options "-O2 -fdump-tree-gimple-details" } */ #include +#include "sat_arith_simplify.h" -#define T uint64_t - -T sat_add_u_1 (T x, T y) -{ - return (T)(x + y) >= x ? (x + y) : -1; -} +DEF_SAT_U_ADD_1 (uint64_t) /* { dg-final { scan-tree-dump-not " if " "gimple" } } */ /* { dg-final { scan-tree-dump-not " else " "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u8.c similarity index 75% rename from gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c rename to gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u8.c index 77e9af3dd29..96e8ecb4af1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-1-u8.c @@ -2,13 +2,9 @@ /* { dg-options "-O2 -fdump-tree-gimple-details" } */ #include +#include "sat_arith_simplify.h" -#define T uint8_t - -T sat_add_u_1 (T x, T y) -{ - return (T)(x + y) >= x ? (x + y) : -1; -} +DEF_SAT_U_ADD_1 (uint8_t) /* { dg-final { scan-tree-dump-not " if " "gimple" } } */ /* { dg-final { scan-tree-dump-not " else " "gimple" } } */ From patchwork Thu Oct 31 06:27:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99891 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95DAD3857434 for ; Thu, 31 Oct 2024 06:31:57 +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.16]) by sourceware.org (Postfix) with ESMTPS id D56463858D33 for ; Thu, 31 Oct 2024 06:29:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D56463858D33 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 D56463858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356200; cv=none; b=mC4LBFWg6480NY7HRDUdjOacYabV90FrGlkH/jWW1t8dkU8yr9g//muqn5Pz9V/xRdTdlyzrAk7B/1myF5dpmDVE1xAzJbJxkZx4jyqM/vG5MHbR2Av8vits9JSjssaV8ET0XQArAvURhR52cqBIt3VywVH5tqrXdjncy8r7e1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356200; c=relaxed/simple; bh=8aLWTJVpZNJ06BgBvBxC4eUH0dPDJamPB+Nxk/9QtO4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vm0i5W3zo1DbWd8wiXvjzcgruB6EEkpceXVkJnZKfOEnYvWZIdh80qJOdwv+sJr7wfU8lazt+8Huqk8op39dcanvdQwvcWtrtzLYCjY4tJyo1EPtPKnSGJr/qXE1hs0Y09n4oPglRskUp5S6531jZ17LQKJkex+3+hn+BUrkJHs= 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=1730356194; x=1761892194; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8aLWTJVpZNJ06BgBvBxC4eUH0dPDJamPB+Nxk/9QtO4=; b=cZrOTGYgCOH78C9omjtrotBR+qV1OTr7QHBHQMQxVLLHOXPU+BfpHgGt qHUcEWih9xALY8B1ONLx4qlS/uc7pPHEZ71vgdsaLuJhh2D316lI2QfjB WhMliwA9Ghw4aBW78NuCvm3PqQkjfo8u/LrpRAFzVOPHN1tYIYqSpvRM9 1uXJv2/vrXA5iYZTpZo9KSo0ZxQoj6KnFGEpsDghUurvqXF6kA+s3DdGm /V7faKXmQjuPxgmHbcndkJJ2jI9R9COSD7IJsP2nuaBH37aNAx6js52Jw JktSmTMmK2P+10uksYX8usVc47nm5G2E2UehSVzagQEfy9wtaYEQI2Zzo w==; X-CSE-ConnectionGUID: RrU7ipRaQbe7F5Be5ESa2Q== X-CSE-MsgGUID: XXiav7eBTfKN+7364NHChQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238452" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238452" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:53 -0700 X-CSE-ConnectionGUID: a5cStxxpRbWx7YHaXT2y4Q== X-CSE-MsgGUID: r/Rp4NZ6QKGdgBWgxYbD/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455062" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:51 -0700 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 v2 07/10] Test: Add testcases for form 5 of unsigned integer SAT_ADD simplify Date: Thu, 31 Oct 2024 14:27:39 +0800 Message-ID: <20241031062742.2709845-7-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 5 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-5-u16.c: New test. * gcc.dg/sat_u_add-simplify-5-u32.c: New test. * gcc.dg/sat_u_add-simplify-5-u64.c: New test. * gcc.dg/sat_u_add-simplify-5-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 9 +++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u8.c | 11 +++++++++++ 5 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 1d66f6f25e3..34fae32ae3a 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -25,4 +25,13 @@ T sat_u_add_##T##_4 (T x, T y) \ return x > (T)(x + y) ? -1 : (x + y); \ } +#define DEF_SAT_U_ADD_5(T) \ +T sat_u_add_##T##_1 (T x, T y) \ +{ \ + if ((T)(x + y) >= x) \ + return x + y; \ + else \ + return -1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u16.c new file mode 100644 index 00000000000..ebfc5c96803 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-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_5 (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-5-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u32.c new file mode 100644 index 00000000000..b1196038739 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-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_5 (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-5-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u64.c new file mode 100644 index 00000000000..d4b31867c5f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-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_5 (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-5-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-u8.c new file mode 100644 index 00000000000..66b1c30d38f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-5-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_5 (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" } } */ From patchwork Thu Oct 31 06:27:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99892 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F37243857704 for ; Thu, 31 Oct 2024 06:32: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 [198.175.65.16]) by sourceware.org (Postfix) with ESMTPS id 9E5A03857810 for ; Thu, 31 Oct 2024 06:29:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E5A03857810 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 9E5A03857810 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356200; cv=none; b=oJzskgdIq4c7lC5PtYMJLdzCmVGhAnJD2akkRp499Y5J4Zu3xA7owFOfkEuiL0PAGgu4TyONS7b33KXhjtdjlwweiGPkpRUyTLM8nA2U80rm9Ar6q3DEeDlEf3/uSpsJLRqHNjPkFd4zaWOtxoBaIXq8ixjWZwn4DpS1GZqc3Kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356200; c=relaxed/simple; bh=8JjeXQ7zD1kqEtuRuZ2yZA1hxj3YyDJX8EnPVCIsnjM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=stczK50JZuaaVxU6PDpm8CxS/YdChPdtbagvUtXDtiV1SrnsM8rYijQP960cqlTJG5LYQiardTCzqkoy0gG1PcsC0SdV4XwUERa90hnMscFW+voC31Tke2KI29UihQ2bNuBJ0knUxrjQ3yJq9LeCbFohTfQfotj8iVYc3uzsUO8= 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=1730356197; x=1761892197; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8JjeXQ7zD1kqEtuRuZ2yZA1hxj3YyDJX8EnPVCIsnjM=; b=UPMxqt96tAfV9AmqmPson/oTZdZY5F5BeKNKSQ6CrZTv7CbVkoT1ALcJ Kjfigw6abpNgS7COxT7NTu2F60c4CYCOvFpxFvwBU2H50x3flCzhjk+lN Y96ANiAa5mO5T1Y7Dnl8Y2ZwnttykaFfe3kxizqm85fOz7plwA6ymPkRy ZXbmHcLcKgroOFkPP91jGOlqDZNWP17T/DPawZ/hIh4wgRSmEbyCpatjr Bo+OuvLv3G8pM6tpXseuM9APeDpjrwI5L+MJ0lBzX2ZyNgL/2krs/gzeK EbXoYmJexWj4WUZIlVA1dTTvLrc581yzTebcO060A5MbbN+ZXm+N/0b86 A==; X-CSE-ConnectionGUID: bsHv0HBJTVOha94sSWS5wQ== X-CSE-MsgGUID: QMxM3USmT6mYHBjd4kn11Q== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238460" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238460" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:55 -0700 X-CSE-ConnectionGUID: Uxx2jQc/Qm+9ToBzzdWwEA== X-CSE-MsgGUID: KVM0++AVQTqctDh8F8mb+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455067" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:53 -0700 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 v2 08/10] Test: Add testcases for form 6 of unsigned integer SAT_ADD simplify Date: Thu, 31 Oct 2024 14:27:40 +0800 Message-ID: <20241031062742.2709845-8-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 6 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-6-u16.c: New test. * gcc.dg/sat_u_add-simplify-6-u32.c: New test. * gcc.dg/sat_u_add-simplify-6-u64.c: New test. * gcc.dg/sat_u_add-simplify-6-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 9 +++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c | 11 +++++++++++ 5 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 34fae32ae3a..d577adb9a88 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -34,4 +34,13 @@ T sat_u_add_##T##_1 (T x, T y) \ return -1; \ } +#define DEF_SAT_U_ADD_6(T) \ +T sat_u_add_##T##_6 (T x, T y) \ +{ \ + if ((T)(x + y) < x) \ + return -1; \ + else \ + return x + y; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c new file mode 100644 index 00000000000..83e6a8993b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c new file mode 100644 index 00000000000..622206486e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c new file mode 100644 index 00000000000..f8ea3c8767a --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c new file mode 100644 index 00000000000..bcd136d899f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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" } } */ From patchwork Thu Oct 31 06:27: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: 99888 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C57C385734A for ; Thu, 31 Oct 2024 06:31:34 +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.16]) by sourceware.org (Postfix) with ESMTPS id 8B0AE3857C6C for ; Thu, 31 Oct 2024 06:29:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B0AE3857C6C 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 8B0AE3857C6C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356209; cv=none; b=nUp5ua8ycySZAJWdAW7v7Muws8bfp2fx6XYkVc8W1ZnYKxcyF1PnWRdom7krf/6zK9Ec4Hmi1Zaf9YTts6Fv4np5T5J1SbDByCPg7EkFXQe6mDwVV7BrrPqa9zR+6/L12BlRTsP2u8pmET72Xszne+6WPEI6aRDOdYrg2lgzZ5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356209; c=relaxed/simple; bh=DRCl64jizD8j56AhARKwCon6I3PBE5HGUZuwRnL18i8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CWyomTuS3jx25ypBCGRgoDoGOt9ZdGaY9J9EIIU02BkiRZdbWeXOZeWTRFq7nF3dUBDW2z+tX2qlN1SdhOqFnWItRql1TVjmfcHYKPePrkvFiZeEQiXpUV99uHB3aPPh3YaOe8Cuux7T/mNg4xo/lOL1/F2WSxKVSGlsBR1Syzs= 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=1730356200; x=1761892200; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DRCl64jizD8j56AhARKwCon6I3PBE5HGUZuwRnL18i8=; b=IJaH/xHTEFYMWbYIwAPEj3PlOA2kEhGcu48ExHX3C5RM9qwgzZ5YUeic 8055jLQnS0tYRRd19/cPN16mbRrStrs0gLK3itI7QGW2tP6biui5hCw4O tUNB6HManKTwCPlCmwcT1cHvZ2M4kxUDQ77nFcKvSouJxPfcJIjNL/qty gWZY83IguZeQpiADoO6Pr7hLI7WLRAW/bO3XlGKrDmCmL6x1fjNYFRkVB IN+8BhdRxUCvK/mA6Fc15sfxlwr7wcfSoGkhuCdKCIwBePO79KS/QsBLc 6BVL7VVTs1sIAn/OyTA0AK+/Aopf8BDxPsS5rX01TIMGe2qzcLc5jkkCz A==; X-CSE-ConnectionGUID: tHgZewdYTAClwn5JAMJN4A== X-CSE-MsgGUID: DykTIt/PRWS4EfXiUwjb5g== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238468" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238468" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:29:58 -0700 X-CSE-ConnectionGUID: bR0wckScTC+s4aGUiEBVpg== X-CSE-MsgGUID: OufYkE7FQFOHTbXdYfl6CQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455072" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:56 -0700 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 v2 09/10] Test: Add testcases for form 7 of unsigned integer SAT_ADD simplify Date: Thu, 31 Oct 2024 14:27:41 +0800 Message-ID: <20241031062742.2709845-9-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 7 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-7-u16.c: New test. * gcc.dg/sat_u_add-simplify-7-u32.c: New test. * gcc.dg/sat_u_add-simplify-7-u64.c: New test. * gcc.dg/sat_u_add-simplify-7-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 9 +++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u8.c | 11 +++++++++++ 5 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index d577adb9a88..a9d183c9abf 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -43,4 +43,13 @@ T sat_u_add_##T##_6 (T x, T y) \ return x + y; \ } +#define DEF_SAT_U_ADD_7(T) \ +T sat_u_add_##T##_7 (T x, T y) \ +{ \ + if (x <= (T)(x + y)) \ + return x + y; \ + else \ + return -1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u16.c new file mode 100644 index 00000000000..1700599e862 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-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_7 (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-7-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u32.c new file mode 100644 index 00000000000..33e649e4cfe --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-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_7 (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-7-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u64.c new file mode 100644 index 00000000000..ab05d833d19 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-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_7 (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-7-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-u8.c new file mode 100644 index 00000000000..17d0068ad30 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-7-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_7 (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" } } */ From patchwork Thu Oct 31 06:27:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99893 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C05C13857706 for ; Thu, 31 Oct 2024 06:33:01 +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.16]) by sourceware.org (Postfix) with ESMTPS id 9945F385771E for ; Thu, 31 Oct 2024 06:30:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9945F385771E 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 9945F385771E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356203; cv=none; b=DQg0NOEP2AD2y+lHxkA72P0E2enITL9VeBdTg1DXfpDX2kFNYIeh/lLGhZiFAPhvsxYLgSOCDZtAJwwweUq4jA27O/LjK8dWz5FNL7OHdIx5F8s4YgTML0xbZP3uCdKpap1iAl46F1FRiFrEX3VlJD63uIAPsr/ekmZFOsPi3+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356203; c=relaxed/simple; bh=ubNL9qYupcoQp8C5V98RI5vVHgkreDcmjsvPrzT/4IE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e9fX4xWGM2Hns9++6hxQNeASXjH/5/XFhCQwa1nl6KmCgssGh8Zy12pncWTN6wpDOS7RoNBOh5GP2LHv+/4Tj4bQWvPGtWVRNoGi0xalcXCOnRHzmp7JWiug8leLPKs4PLUcM7ND6GmFEJQmYZI7g9i0bECEbUemDuU2l5myWsE= 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=1730356201; x=1761892201; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ubNL9qYupcoQp8C5V98RI5vVHgkreDcmjsvPrzT/4IE=; b=QyYKKvQF5VfhUrpxfukss4EBep7VY67uiDXt8TWp9Sy703d/l8gpTRMN qm53BAZQkLLNCjtuky2u1ICJZCCIQYJhIi/sw3H41zBFkrG9HUd0pyvaf 6SUJNviFYUjLOck0fVtS6BFN3GWsFIsfUAYX4IOxGy0Hd2qQulmGlewUz RfJ3rUYCbVu9pCf2rGPMVx8diYIaktUfgdiVCzZHesDVpNuSJknN9gc3B S41RVG4KESqaLw/NPPXaZ3Dxe+cDcOy6G6Q26oV+1z/5qEHF720G9cY7F WDMiFGoafGZ8lqLGpd9BPaYPQj0bqeyS87FSLvpgYu3x1iaNHCiBrOu3E g==; X-CSE-ConnectionGUID: k45FotWzR/WTLDTBTPwcLg== X-CSE-MsgGUID: JChioIBdSH+kLPFwVIzsrg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238474" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238474" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:30:00 -0700 X-CSE-ConnectionGUID: r7FlCUxbSmK7j1cIHdM6Dg== X-CSE-MsgGUID: 9PMzizH2RZOCknBNRZd1gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455078" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:58 -0700 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 v2 10/10] Test: Add testcases for form 8 of unsigned integer SAT_ADD simplify Date: Thu, 31 Oct 2024 14:27:42 +0800 Message-ID: <20241031062742.2709845-10-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~patchwork=sourceware.org@gcc.gnu.org From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 8 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-8-u16.c: New test. * gcc.dg/sat_u_add-simplify-8-u32.c: New test. * gcc.dg/sat_u_add-simplify-8-u64.c: New test. * gcc.dg/sat_u_add-simplify-8-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 9 +++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c | 11 +++++++++++ 5 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index a9d183c9abf..3d4ec184452 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -52,4 +52,13 @@ T sat_u_add_##T##_7 (T x, T y) \ return -1; \ } +#define DEF_SAT_U_ADD_8(T) \ +T sat_u_add_##T##_8 (T x, T y) \ +{ \ + if (x > (T)(x + y)) \ + return -1; \ + else \ + return x + y; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c new file mode 100644 index 00000000000..1a38931fd74 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-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_8 (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-8-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c new file mode 100644 index 00000000000..b333ce5e407 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-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_8 (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-8-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c new file mode 100644 index 00000000000..2f0e18e4a17 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-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_8 (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-8-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c new file mode 100644 index 00000000000..97878e127f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-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_8 (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" } } */