From patchwork Tue Oct 29 08:25:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99747 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 59BBF385841E for ; Tue, 29 Oct 2024 08:29:41 +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.18]) by sourceware.org (Postfix) with ESMTPS id 5A21E3858C42 for ; Tue, 29 Oct 2024 08:27:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A21E3858C42 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 5A21E3858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730190454; cv=none; b=xAuC+7XAzjJTG+CObcLbiliqDwWIwq6dA0y0+k9akYg85SuknfOQho1tShW7bXLPcS3U14E7sqk9JOsw9OqnC/BacxCPckstSRvuLF1jcmTBOnrw6lgwqTdcKgDeF5CY1tXV5f03mImtYXY/5IJKbG+PlxtUdG7rYYdAnRmNM5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730190454; c=relaxed/simple; bh=zOlRv/lDR3T0ag+jHPYFaE/rb4xka82NpKMHvnfeZLQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ba3NfSK2p2ZQrtGT2GWkuSNhmfaNv1Vj5EIbod56AIFhUT/KAWEJS4MFaARjdwCdVIHs6BWMHxve3RugELdrShjLRSEQKwFzsRMZ8rrTjfEnKev3PsFEGy0bUwnz2l18rGrDxbK5AOI+h3AkKw0Hk5hIYplwScx9szlhVbchl64= 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=1730190451; x=1761726451; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zOlRv/lDR3T0ag+jHPYFaE/rb4xka82NpKMHvnfeZLQ=; b=W+L5hR/XNLCO6Yf/gwax0OKSwXn4Lu4GATf1Ah7s+r1/pebcH5Lb6mFr EsmSSFRIRYVO2OMLULDTO908vvS+dTS8A6glbwYX9EMi9uc4IrWWO57c7 DQeeh/aYe4JbljsmDbd3rOewMoypv6H6UmLiHNIa6YonWOpoqgk5X/gHy GNlCMTRUyYxti3wQxZBWowfPLchJ8ILFjHtZZDxUd2m0TPhekc2msXi53 0gkKbTAENGl7Ip2bD3gScCBZR1eo17gTkRXxNaXvJT8/fvnQJ/jeKoVeZ 2s0Gp9v3yz8so3kZFAqIDnS1a3NWjtkwYIzJ34wjlTUhpIWytOe69IRQl w==; X-CSE-ConnectionGUID: lFIj9mZgTsKcEaNL5tW9WA== X-CSE-MsgGUID: 7crgbVv8RbGNuWoDIhVaKA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30002116" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30002116" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 01:27:23 -0700 X-CSE-ConnectionGUID: OFAc2mWgQdO1g3X+8/jPGQ== X-CSE-MsgGUID: rL3vfp5VR52ht8AkHVABrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="86652651" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa005.jf.intel.com with ESMTP; 29 Oct 2024 01:27:21 -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 5/5] Match: Update the comments of unsigned integer SAT_ADD [NFC] Date: Tue, 29 Oct 2024 16:25:21 +0800 Message-ID: <20241029082521.3638409-5-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029082521.3638409-1-pan2.li@intel.com> References: <20241029082521.3638409-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 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 a804d9c58fc..8dd7f9af62e 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))) @@ -3171,13 +3175,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_ior @2 (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))) @@ -3199,7 +3205,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))