From patchwork Fri Jan 26 01:16:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 192346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp373126dyb; Thu, 25 Jan 2024 17:17:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3AsJFEn+rkdworwRPayQ234kE5Bj18NQsPvcORnBbNcEzeFxW5kgn9bqNDLuW10BOb96d X-Received: by 2002:a05:620a:4252:b0:783:bdb3:5922 with SMTP id w18-20020a05620a425200b00783bdb35922mr794511qko.103.1706231862691; Thu, 25 Jan 2024 17:17:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706231862; cv=pass; d=google.com; s=arc-20160816; b=yZjgPszAHS+f6y8+P6VnnQvAVgeBFbAZdXatdkIi7vqB6G3Xv82N+jfzbuv+jdUuES Vn8roacXZVSjjHGHR5K//KeA61wBJIfuR6HUkOqlsuF1uLEJy4+eEBryaKSrEuPuwhdB J8W8Ptf6G7pbcyf1PFSOWCzPxtAus5nMieXT1lRwp1CYpe6AmtUXo9FhERGUWb6na4Uu qu6Hj+6lf0Ixjs+XPOGqsr7uljwuRVtHoqUaLFfdv3s760uG1RqZNgQ1kvqoz05dikWI XQ4y4T/r29Og78TjdIvcD6Y3i/dLUWY7QufqEWzv4TZV1zNgYcDEm5tT+uWWK4MSWTRu u0VA== 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=Vqu1jKl2/H737H81w875wkyCcox5DRyr+zsKt9DSXUQ=; fh=3eUSxJU+9IWNwGHlMjnmqDQDnJfeMKAjlglEUO7a4vw=; b=gcEKQ13HP26IzJW+yrMhBaFM3RYY8j8CwD80L8JRgIjgUktRt3/qwLq83ye7wfBEo0 Dl7pjCL4MtSbo7rKcERS5Nuv3wcgD14O842KBZqKLzhv5VHhsZcm4L3yTuGpl4Q9erk3 NgdDhoDh1Wt7uaQRNXOFU3HYIS/SelR4tkIha1ND2aQEvmQWjc3hoL00nPH6TlD/YRA1 ATeRvtqkVleiuHhtdp+XXkKvC85qJhAz2h/TmFAbCpcj1iy0+ssFFSuPLb2J7A9zqfE7 iKF+ELmUzVVnEunif23HE1wESDyzu9sJAeiUzj913BTwYf5zCbMKytMOHG9v+PSxtJLM R6Ig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="C32Eh/by"; 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 bs33-20020a05620a472100b007833600c1cbsi288559qkb.19.2024.01.25.17.17.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 17:17:42 -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="C32Eh/by"; 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 5BEF13858C66 for ; Fri, 26 Jan 2024 01:17:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id C2DF33858D28 for ; Fri, 26 Jan 2024 01:16:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2DF33858D28 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 C2DF33858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706231818; cv=none; b=mLS88dJ4uG3alhvo1HbHuPUocZiXSpeQgBVo/QILVs3pGsOQKZW+hSPyR2XUSEtfHXDGvfIur5n/+JEia48NhC3RBWcekRxSvwdaVR5L+6SUQYD8RgjjdtECue36+qiXJSTBfzdvEhls21xBp3qf9PV7dYwPOOM1exQs1S7amSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706231818; c=relaxed/simple; bh=GYY0WYVSLCWc0QtrGTc2O53Cx1o4HQDOX5kLOjzUHAU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=nQXka9g1DF3CI4azLdfx/9UPsxcwQnRnWKYNS6HRd5nCKxcWkSb8IQgGVtZ4HIyXfNjzl2Qcd5sNndawwtuvJE+3G8pFXrA2ZgJThYsrdPCRpsWuvivG25AjilT7iA/nb35LYZWlY1HcxlfsJg+acM7ECdlrktPGttErM3Af9hU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40Q0sxpJ003354; Fri, 26 Jan 2024 01:16:55 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=Vqu1jKl2/H737H81w875wkyCcox5DRyr+zsKt9DSXUQ=; b=C32Eh/bySooCU3fUQ2+Uf3HTbs+cZj4fEacv/MafqdO4/WAYJcc0WstzU5GKybeuBgsS evgGX/cnNMYalmy7usb88L2M9DPfqtiyiTPZbeg1jgG5poUaCrdbLozMqFCScMv7qRxk d2UcIVnx3TRv2gVeciQqdl/Rq2QpZ8XWBrQ4iHSrYDqOhlOEMV+k1dC3FOmEjNHFaGqm Mw0nTgEpVUZLymF/hn9Bv8smlUStskfsJfQA5gBqE5SrZEEl9ZL123F0zp4r8tDBWmEG CnPUl5MQBGRwwJ6rc25TAz7/6qNl6wV56SFe9Rh1ou/cNmWw6lKS60xDpBngTxyhcv0u 7w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vv1udsfpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 01:16:54 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40Q0ba0X031441; Fri, 26 Jan 2024 01:16:54 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 3vv1udsfps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 01:16:54 +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 40PNkAD2028233; Fri, 26 Jan 2024 01:16:53 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vru72yb9c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 01:16:53 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40Q1Goll28246726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Jan 2024 01:16:50 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D8B420040; Fri, 26 Jan 2024 01:16:50 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C10C820043; Fri, 26 Jan 2024 01:16:48 +0000 (GMT) Received: from [9.197.238.75] (unknown [9.197.238.75]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 26 Jan 2024 01:16:48 +0000 (GMT) Message-ID: Date: Fri, 26 Jan 2024 09:16:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner From: HAO CHEN GUI Subject: [PATCH-1] fwprop: Replace rtx_cost with insn_cost in try_fwprop_subst_pattern [PR113325] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: c0Jdk_9H8jDrUjSiUIVfEokyqcHLxrfj X-Proofpoint-GUID: J9GvmyPKLDqo0hN6If7LjJP9ZOynY9YD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401260008 X-Spam-Status: No, score=-12.0 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: 1789113781324632564 X-GMAIL-MSGID: 1789113781324632564 Hi, This patch replaces rtx_cost with insn_cost in forward propagation. In the PR, one constant vector should be propagated and replace a pseudo in a store insn if we know it's a duplicated constant vector. It reduces the insn cost but not rtx cost. In this case, the kind of destination operand (memory or pseudo) decides the cost and rtx cost can't reflect it. The test case is added in the second target specific patch. Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no regressions. Is it OK for next stage 1? Thanks Gui Haochen ChangeLog fwprop: Replace rtx_cost with insn_cost in try_fwprop_subst_pattern gcc/ PR target/113325 * fwprop.cc (try_fwprop_subst_pattern): Replace rtx_cost with insn_cost. patch.diff diff --git a/gcc/fwprop.cc b/gcc/fwprop.cc index 0707a234726..b05b2538edc 100644 --- a/gcc/fwprop.cc +++ b/gcc/fwprop.cc @@ -467,20 +467,17 @@ try_fwprop_subst_pattern (obstack_watermark &attempt, insn_change &use_change, redo_changes (0); } - /* ??? In theory, it should be better to use insn costs rather than - set_src_costs here. That would involve replacing this code with - change_is_worthwhile. */ bool ok = recog (attempt, use_change); if (ok && !prop.changed_mem_p () && !use_insn->is_asm ()) - if (rtx use_set = single_set (use_rtl)) + if (single_set (use_rtl)) { bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (use_rtl)); + auto new_cost = insn_cost (use_rtl, speed); temporarily_undo_changes (0); - auto old_cost = set_src_cost (SET_SRC (use_set), - GET_MODE (SET_DEST (use_set)), speed); + /* Invalidate recog data. */ + INSN_CODE (use_rtl) = -1; + auto old_cost = insn_cost (use_rtl, speed); redo_changes (0); - auto new_cost = set_src_cost (SET_SRC (use_set), - GET_MODE (SET_DEST (use_set)), speed); if (new_cost > old_cost) { if (dump_file)