From patchwork Tue Jul 2 01:38:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1954980 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=b9nA1PGb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WCltX3lWnz1xpc for ; Tue, 2 Jul 2024 11:38:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA0DE3835406 for ; Tue, 2 Jul 2024 01:38: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.13]) by sourceware.org (Postfix) with ESMTPS id 05CEA3858CDA for ; Tue, 2 Jul 2024 01:38:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05CEA3858CDA 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 05CEA3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719884301; cv=none; b=uYRZZhNeH8jYsZcu40sUEQpUvUvVCfZWgCC0hQqxpEgWHQbpcWbSg38wdBgUza4JRb4Fht/qCQiCeuwhLVJf+H3VN7j9IiMij4342sIMEVuJXFG2QxOvh4yURgJIQ7wkyUvmtn++YneDPZ2lZI64l1hxnWGdVTPGSGWi43MsMeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719884301; c=relaxed/simple; bh=VeRlIlhu237Ff/D/v7H/piJskzhA8k0hbGFRD5LxUaA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=X9DyDTaSiWj+U3+dk0k2zio046TvR6E6dBybzcCI3pPnJ5pOoRt7SlTtqMTwbVF4L7TvtlwfpxLchmYrSHZ7wbhE2oY0G075ktU65hHCAbYlwJRxnPZ0aRN1N30mqvW9tNrECGvEXb4b/OKso67yRz8PPHmrzj4wEXtidymFi5w= 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=1719884299; x=1751420299; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VeRlIlhu237Ff/D/v7H/piJskzhA8k0hbGFRD5LxUaA=; b=b9nA1PGbeQ5N0JmVASi5cV1RBY4f6wxYViGz+ZiU0dt8aBBKQFQg1FBT LUYhdpZtr2sRLIlGBogn1OkEeRQhnVz8n9AHcjaDI9+Nx5yrN1o4kQx3w 0UCW4QfTv6rPE4c3JwMAZ1xH0cnKrlZALDpz4tWAaL2y5qR0XUlWSTuQJ 9ZSdDC9UDf8cWcaNBElfKU46jaFQb3+VhyXjz+U0bX0xv8Iz5DqZ8HM1+ xX5+NQlHIiXzrCFlJ9G0O6lLdXKZH3lv8OI6LuV5Y1Z30ZSSAPCLMcDfp XeydjVu/xVAZtqSy37IdWPmjHC/X7DAQqjgVA/3OSr33EJXu2+XYKzCcY Q==; X-CSE-ConnectionGUID: 8eSwkbV+TBCpb4hvVdFIKg== X-CSE-MsgGUID: 0NK0jfiWRZ+dq1g6HZYgBg== X-IronPort-AV: E=McAfee;i="6700,10204,11120"; a="28170462" X-IronPort-AV: E=Sophos;i="6.09,177,1716274800"; d="scan'208";a="28170462" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2024 18:38:18 -0700 X-CSE-ConnectionGUID: +PaVTeRtTU+LKb4U9pFKyw== X-CSE-MsgGUID: /hWPL70CS4SNeXXJoADy7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,177,1716274800"; d="scan'208";a="45622645" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmviesa007.fm.intel.com with ESMTP; 01 Jul 2024 18:38:11 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id B8BBD100735E; Tue, 2 Jul 2024 09:38:10 +0800 (CST) From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, richard.guenther@gmail.com, tamar.christina@arm.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v1] Match: Allow more types truncation for .SAT_TRUNC Date: Tue, 2 Jul 2024 09:38:09 +0800 Message-Id: <20240702013809.2649409-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 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~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Pan Li The .SAT_TRUNC has the input and output types, aka cvt from itype to otype and the sizeof (otype) < sizeof (itype). The previous patch only allows the sizeof (otype) == sizeof (itype) / 2. But actually we have 1/4 and 1/8 truncation. This patch would like to support more types trunction when sizeof (otype) < sizeof (itype). The below truncation will be covered. * uint64_t => uint8_t * uint64_t => uint16_t * uint64_t => uint32_t * uint32_t => uint8_t * uint32_t => uint16_t * uint16_t => uint8_t The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The rv64gcv build with glibc. 3. The x86 bootstrap tests. 4. The x86 fully regression tests. gcc/ChangeLog: * match.pd: Allow any otype is less than itype truncation. Signed-off-by: Pan Li --- gcc/match.pd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 7fff7b5f9fe..f708f4622bd 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3239,16 +3239,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (match (unsigned_integer_sat_trunc @0) (bit_ior:c (negate (convert (gt @0 INTEGER_CST@1))) (convert @0)) - (with { + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && TYPE_UNSIGNED (TREE_TYPE (@0))) + (with + { unsigned itype_precision = TYPE_PRECISION (TREE_TYPE (@0)); unsigned otype_precision = TYPE_PRECISION (type); - wide_int trunc_max = wi::mask (itype_precision / 2, false, itype_precision); + wide_int trunc_max = wi::mask (otype_precision, false, itype_precision); wide_int int_cst = wi::to_wide (@1, itype_precision); } - (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) - && TYPE_UNSIGNED (TREE_TYPE (@0)) - && otype_precision < itype_precision - && wi::eq_p (trunc_max, int_cst))))) + (if (otype_precision < itype_precision && wi::eq_p (trunc_max, int_cst)))))) /* x > y && x != XXX_MIN --> x > y x > y && x == XXX_MIN --> false . */