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