From patchwork Thu Nov 23 01:22:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 168680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp203248vqx; Wed, 22 Nov 2023 19:51:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQEhJW8RcxZdi3KvCRoH6Fj8tj4D7XJZQVrdg5jRPd6xVixoXYfp9ToxqBC/aBJjvNJxh6 X-Received: by 2002:a05:6102:a4b:b0:462:8fc4:3ce7 with SMTP id i11-20020a0561020a4b00b004628fc43ce7mr5765244vss.25.1700711462708; Wed, 22 Nov 2023 19:51:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700711462; cv=pass; d=google.com; s=arc-20160816; b=Nq57Jpc3zt/5W6Qkx6Vc1nI+AZCWl8VhxCrIFVXW2sWKnclqlbK7/Gsl+fqmoyoVFT 4uwmTll3jMGp/gT804yI2dXCkvGhVvk3Baqw9fQgBKi2QVQlVQjITFg8OvXmzHiPaDAM ONX9psQFsgIezmkSctPMExzAZKXmfdNJCbLhNIY6WkCHVVaBVONki9w3TLy5Kbed7UPN a8sJmq6klsR9qXlFGcM/uZlAHSctl1P1IAdD0V/pL3Q8RooKV5N8ixxHYrXYiKx3LdQW XtBrxAE4TA6AFtFZKXE6QScW8gEBOwsFLIVBJej4NUsSIg9EBKDGXdLbNRbkgm0DoHsl 0BCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=OqxkGOwWHD46Lbamm4asTebHa2BdF0RR+DTIDlwlOD0=; fh=lLZP3uHhXiSbgwP2B1KoLJRAVcgP5GU+moaWEakPPkg=; b=sRUfIrhpwOLdGMVjod+g8sd4XgxydJPU6UWZfbSvsVgGBTXhAQLSdmtrm0DnXryJ+p 4URkJRtRXC1FSb1PRHykqu5YUDehzozTa9DUXow5c65sol6jjdpoSUfhJwVzudHQGsiz IvNEZ4LPwvKTzM8m/NlLYToQBIWGEJqF8wDKjBv5GWx4ATnb5h4m0wnr5BZW06EuU7Lv Qq7OeZ12/QHwycr1m5kSndA5coKtAsgBWulzw6KPEwXejVz0eFYBcj2+HVDtaELoFXn4 QtmCvXC+0lHs4SAmo+64LPiWXBOxXWwHUfokYuqRzPaqCHqkSjgA7kv/fn4Kl7xuhZtR pULQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=sdP9BwHs; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a6-20020a05622a02c600b0041cbb5e5a86si383186qtx.428.2023.11.22.19.51.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:51:02 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=sdP9BwHs; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7FC303906519 for ; Thu, 23 Nov 2023 01:24:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id DE6BC38F912F for ; Thu, 23 Nov 2023 01:22:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE6BC38F912F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DE6BC38F912F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700702563; cv=none; b=bW+eORtLKgr6l6O9ELjs+mwsE7HMkou7//JLETbJNvKTgsr35jfmpPl2G4rUiup50PETkuNBpoOJu+SWSNrsBBA1R2ozDkjq+fb/6jHwrlE9XAJRJQWU4PnGbJV3SaIq0CMcinCHxov03UYMkWYjWj4q5AmUcS6yhi4YO7AUfx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700702563; c=relaxed/simple; bh=pfjbecXH4iLB1ic/3241b1JUUvE1SmGyugo7XxAWyjk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=n4Sz+3jluAA+PaTYsjRxYTYe3VrPhJaVwCo8UV0aoxydv1xpTiSKWuguo0RAOR6mtTrKFq1N1M2O95gCxX7xxDckkxr2tWUlMZhfndLzRpkVMlnKF+AklwUg3/83MYel+EQTUkIefdJZJCy26QAX0AXqN3dCcibHX8iFFlGOiqY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN17kpk028270; Thu, 23 Nov 2023 01:22:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=OqxkGOwWHD46Lbamm4asTebHa2BdF0RR+DTIDlwlOD0=; b=sdP9BwHssSZ38AZATj/q4ADe5JU+beJwQ38NovOyPrEvd7P5amPNkEa2MMQenpn/J5O5 3ACfAOAx1MzKLRXCNTuEmTZxXlWP3+i/hpPPtZ32iBoYoOgBKzzezz5Mgxl8VRH3OoN2 JrdxIs7jczDmEvuXf2BfPlvCJfPUNsUVglWHAShvJIVUopKxJ9smmNO3LL7xmBFFdjKw ZHM0kJ5NN5rTxsm3QKagZxrgRwzBWqA9Y7rszfHrKXUYQDVXO0rv0oQS14qO7Kvj5LtM 51THYc3RVfyryxBebBneL+pgmymfJblfO7OCPe9AfKEvyCR2tFP0mA8OZeEm4ZlOGE65 Sw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uhvsxg5r7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 01:22:37 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN1IJd2017497; Thu, 23 Nov 2023 01:22:36 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uhvsxg5qv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 01:22:36 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AMNmf7G001180; Thu, 23 Nov 2023 01:22:35 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ufaa2bj3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 01:22:35 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN1MWDW12845624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 01:22:32 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C818520040; Thu, 23 Nov 2023 01:22:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E9CE20043; Thu, 23 Nov 2023 01:22:31 +0000 (GMT) Received: from [9.200.103.64] (unknown [9.200.103.64]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 01:22:30 +0000 (GMT) Message-ID: <447b3443-49b7-4c39-a4f5-0eb07da378dd@linux.ibm.com> Date: Thu, 23 Nov 2023 09:22:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner , Richard Sandiford From: HAO CHEN GUI Subject: [PATCHv2] Clean up by_pieces_ninsns X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: xUr4mmS4RDO-7xybBzWUKQ3cjN_v4Rv6 X-Proofpoint-GUID: ZmioArR9Q2P7INzq4lr5yR1mC4HS2kqs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-22_18,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=1 impostorscore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=1 mlxlogscore=430 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230008 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783325222792076815 X-GMAIL-MSGID: 1783325222792076815 Hi, This patch cleans up by_pieces_ninsns and does following things. 1. Do the length and alignment adjustment for by pieces compare when overlap operation is enabled. 2. Replace unnecessary mov_optab checks with gcc assertions. Compared to last version, the main change is to replace unnecessary mov_optab checks with gcc assertions and fix the indentation. Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no regressions. Is this OK for trunk? Thanks Gui Haochen ChangeLog Clean up by_pieces_ninsns The by pieces compare can be implemented by overlapped operations. So it should be taken into consideration when doing the adjustment for overlap operations. The mode returned from widest_fixed_size_mode_for_size is already checked with mov_optab in by_pieces_mode_supported_p called by widest_fixed_size_mode_for_size. So it is no need to check mov_optab again in by_pieces_ninsns. The patch fixes these issues. gcc/ * expr.cc (by_pieces_ninsns): Include by pieces compare when do the adjustment for overlap operations. Replace mov_optab checks with gcc assertions. patch.diff diff --git a/gcc/expr.cc b/gcc/expr.cc index 556bcf7ef59..ffd18fe43cc 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -1090,18 +1090,16 @@ by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align, unsigned HOST_WIDE_INT n_insns = 0; fixed_size_mode mode; - if (targetm.overlap_op_by_pieces_p () && op != COMPARE_BY_PIECES) + if (targetm.overlap_op_by_pieces_p ()) { /* NB: Round up L and ALIGN to the widest integer mode for MAX_SIZE. */ mode = widest_fixed_size_mode_for_size (max_size, op); - if (optab_handler (mov_optab, mode) != CODE_FOR_nothing) - { - unsigned HOST_WIDE_INT up = ROUND_UP (l, GET_MODE_SIZE (mode)); - if (up > l) - l = up; - align = GET_MODE_ALIGNMENT (mode); - } + gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing); + unsigned HOST_WIDE_INT up = ROUND_UP (l, GET_MODE_SIZE (mode)); + if (up > l) + l = up; + align = GET_MODE_ALIGNMENT (mode); } align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align); @@ -1109,12 +1107,11 @@ by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align, while (max_size > 1 && l > 0) { mode = widest_fixed_size_mode_for_size (max_size, op); - enum insn_code icode; + gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing); unsigned int modesize = GET_MODE_SIZE (mode); - icode = optab_handler (mov_optab, mode); - if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) + if (align >= GET_MODE_ALIGNMENT (mode)) { unsigned HOST_WIDE_INT n_pieces = l / modesize; l %= modesize;