From patchwork Wed Nov 15 02:26:28 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: 165141 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2343339rwb; Tue, 14 Nov 2023 18:27:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0hpN4RZ+ay6Yontxq0/fLAX+vu0gr7y2rImd7cHmm5pF5NKhxzXry2o9wGLQWRDSkBxjZ X-Received: by 2002:ac8:5bca:0:b0:418:225d:e9d2 with SMTP id b10-20020ac85bca000000b00418225de9d2mr3549766qtb.52.1700015226440; Tue, 14 Nov 2023 18:27:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700015226; cv=pass; d=google.com; s=arc-20160816; b=ABmuy5rLAqkGoECqZEXAGbq9czKvnHsZSWFQg4bnuyU3MOeJENyIotYirbXiC/pXoQ 39S7S+O5BcSR+gamOesxKS6AyedNhq7SbdEgRcdinZ5oAxES50VQJJpnN2v131gqrKbl Um6Z/tFKwYl9XYcHuGtCKtdskRDrSCkHJdDjTPud/0+WvY3GHWGsWaF2mcrbk9DyLOEQ kUzy8L/k8ejd3Jut2q9grWZdRAuJFjaobTF8mcj18r2gWuiBV1DF7F2ifEHImRnvxAfH QO78MywZbuIk5d17D2fVG/F4+ZeuDOxAsyKKAQajDu5f72ZybcKOgJcrWWlRGN7L6vs/ cwZA== 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 :in-reply-to:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature:arc-filter :dmarc-filter:delivered-to; bh=5AJKyD9/VqU54X07WEfEM6PKbjnU1v4czMDCeQQexaY=; fh=lLZP3uHhXiSbgwP2B1KoLJRAVcgP5GU+moaWEakPPkg=; b=hkI+4NXblTDDuRLaxZPBz+7Me6geJaZwtoYFHlewvetHklCw6eGvi7/c3PwR4PgSuY XfdZRZsrVeiW4pvMg6aQDl3uU6FZJMX5A6CPzaYrfS1+HvyLUL0aPisiU/Ke2p0gD3T+ DFGnL+8CUukScGRbZ7qc/20CHVTMLDHhuWmlg073QbFA3CV7LsdHKidpDdYgYxe5JztJ njf6m4iFaiL0UUUcueIRqBaQws7vBq+KAUhr1tXmc+oU4bX+vBndEvqJWZVOv/UFKLFr lOI6kGXASqqOYUFE3Toj7GrMtJrR4U4zOiHq9uytGAascumgr6djbVAPUupKQo1+cKO1 RMOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Spz1NNV3; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id c14-20020ac85a8e000000b0041822134c6asi7767991qtc.158.2023.11.14.18.27.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 18:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Spz1NNV3; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 2F7A73858C54 for ; Wed, 15 Nov 2023 02:27:06 +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 262823858CD1 for ; Wed, 15 Nov 2023 02:26:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 262823858CD1 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 262823858CD1 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=1700015203; cv=none; b=mOLVBYhcgKNz/hhAQ6k3pJC/HEiDz0lpKHNPQDOQLose/8wqkAHuuRWxCNJIj+Q3GiTdEvi5mXEWJHBm5miuKfOpHs14RrwTWJ9t3BV8MhyDSddPUGE03Ak1RD2/FLTcLfvUo8j7qg6c7cAMDJ1vRQZNtqh/4yxy+/miQUO0v9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700015203; c=relaxed/simple; bh=7/Vo4W5LNl0MQ35bO0373iUOFKKWfdun30Ackp2zx/c=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=BbMoTahqbKhVRtTR9Z3PSc7qOCY792sSrFbRh/tABZ4iZ8U9IC0kdev9aUpfl3L8UxZeGPsh/YzJBF1/okWpbOXE/jvt3N8W5EtnSDJlS6Ab7NsRbIMWBa4FwiXZ0ZU6uMzyQvWvsBhEgY+E4nkek68GD9Nw8RHrUMhawtyuQ8s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AF1HHGd029040; Wed, 15 Nov 2023 02:26:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : from : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=5AJKyD9/VqU54X07WEfEM6PKbjnU1v4czMDCeQQexaY=; b=Spz1NNV3M2NnimkV+mYk2iQwlXRomSBA04tQKCh6UdbD+WnQIPBuoLGzdCOewaw/7LfC EdxErgFmER+//80D2g5LfyI0ID4DU8RzAE1p3jy5Fur0q5+rICGLhIKmrvTe0D/+aao1 QcDOUCsXzvWsfZ86uJU1PNFv4pgicRme2/FclLBbGl7tijx1U3TsQutJwb8SxDNSSkvH tKVH1gROHjHJl49OyAl+I259+rOgCufVXCs09mXhK9WPNLxhPQDmJrW4hYlBhGSeL0Xj A2HcMYVyrNEmNzeX2eXzDRw+MuUJyGep9AW28qVN0rUp1y60pMLLJRHYKIBLpuhuGjWB OA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ucm6khhn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 02:26:36 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AF2NjD0014554; Wed, 15 Nov 2023 02:26:35 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ucm6khhkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 02:26:35 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AF1KJLe024344; Wed, 15 Nov 2023 02:26:34 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uamayceba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 02:26:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AF2QUVh20054744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Nov 2023 02:26:31 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0E9920043; Wed, 15 Nov 2023 02:26:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38E7A20040; Wed, 15 Nov 2023 02:26:29 +0000 (GMT) Received: from [9.200.103.64] (unknown [9.200.103.64]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Nov 2023 02:26:28 +0000 (GMT) Message-ID: <87edf7bc-1096-486d-a029-f6a3450739c9@linux.ibm.com> Date: Wed, 15 Nov 2023 10:26:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH] Clean up by_pieces_ninsns Content-Language: en-US From: HAO CHEN GUI To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner , Richard Sandiford References: <4d66d2b2-94d7-4955-81a3-83622c00585a@linux.ibm.com> In-Reply-To: <4d66d2b2-94d7-4955-81a3-83622c00585a@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: G86zLv80VTa_-K2JsDaee4l9a--lNWal X-Proofpoint-GUID: oMsrXopXvu-0OcsCRfAjt200P8My8u7f 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-15_01,2023-11-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 malwarescore=0 impostorscore=0 mlxlogscore=603 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150019 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: 1782595166428901104 X-GMAIL-MSGID: 1782595166428901104 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. Remove unnecessary mov_optab checks. 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 there 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. Remove unnecessary mov_optab check. patch.diff diff --git a/gcc/expr.cc b/gcc/expr.cc index 3e2a678710d..7cb2c935177 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -1090,18 +1090,15 @@ 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); - } + 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 +1106,10 @@ 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; 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;