From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id C62B9385841F for ; Thu, 24 Feb 2022 05:56:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C62B9385841F Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21O5a5Jx026665; Thu, 24 Feb 2022 05:56:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3edwke7726-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Feb 2022 05:56:57 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 21O5a9C7027101; Thu, 24 Feb 2022 05:56:56 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3edwke771v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Feb 2022 05:56:56 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21O5mYe5021926; Thu, 24 Feb 2022 05:56:55 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma02dal.us.ibm.com with ESMTP id 3ear6bgbku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Feb 2022 05:56:55 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21O5utKh47710470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Feb 2022 05:56:55 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDC50112061; Thu, 24 Feb 2022 05:56:54 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E527112064; Thu, 24 Feb 2022 05:56:54 +0000 (GMT) Received: from genoa (unknown [9.40.192.157]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTPS; Thu, 24 Feb 2022 05:56:54 +0000 (GMT) From: Jiufu Guo To: Segher Boessenkool Cc: Richard Biener , gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, jlaw@tachyum.com, wschmidt@linux.ibm.com Subject: Re: [PATCH] Check if loading const from mem is faster References: <20220222065313.2040127-1-guojiufu@linux.ibm.com> <70r5oq10-988r-3rns-356-o3s79o292nn0@fhfr.qr> <1d471fba-a966-3e90-92ce-ae4707fe53b6@linux.ibm.com> <7ns67pr-q7q-rps-136-37pn481515q5@fhfr.qr> <20220223211406.GH614@gate.crashing.org> Date: Thu, 24 Feb 2022 13:56:49 +0800 In-Reply-To: <20220223211406.GH614@gate.crashing.org> (Segher Boessenkool's message of "Wed, 23 Feb 2022 15:14:06 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SR49AlwlmU4xfic0jm4ed4HveTcgcOgC X-Proofpoint-ORIG-GUID: Te1M02-J4UoE8_sHvWWI_h3AB5PcXo_3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-02-23_09,2022-02-23_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=805 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202240031 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 05:57:00 -0000 Segher Boessenkool writes: > On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: >> I'm assuming we're always dealing with >> >> (set (reg:MODE ..) ) >> >> here and CSE is not substituting into random places of an >> instruction(?). I don't know what 'rtx_cost' should evaluate >> to for a constant, if it should implicitely evaluate the cost >> of putting the result into a register for example. > > rtx_cost is no good here (and in most places). rtx_cost should be 0 > for anything that is used as input in a machine instruction -- but you > need much more context to determine that. insn_cost is much simpler and > much easier to use. > >> Using RTX_COST with SET and 1 at least looks no worse than using >> your proposed new target hook and comparing it with the original >> unfolded src (again with SET and 1). > > It is required to generate valid instructions no matter what, before > the pass has finished that is. On all more modern architectures it is > futile to think you can usefully consider the cost of an RTL expression > and derive a real-world cost of the generated code from that. Thanks Segher for pointing out these! Here is another reason that I did not use rtx_cost: in a few passes, there are codes to check the constants and store them in constant pool. I'm thinking to integerate those codes in a consistent way. BR, Jiufu > > But there is so much more wrong with cse.c :-( > > > Segher