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: 1867556 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=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=sdP9BwHs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4SbL3p55wnz1yRw for ; Thu, 23 Nov 2023 12:23:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4603A38AA262 for ; Thu, 23 Nov 2023 01:23:48 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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;