From patchwork Mon Jul 29 05:07:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 1965826 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=BrSCvPrj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WXRGT24k5z1yYq for ; Mon, 29 Jul 2024 15:08:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57B4D385AC29 for ; Mon, 29 Jul 2024 05:08:45 +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 691743858C60; Mon, 29 Jul 2024 05:08:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 691743858C60 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 691743858C60 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=1722229692; cv=none; b=HZjGLY0/VLr9zVgD5XpaBQRlxN8FN1EMpXP44zI5EWwYCsq72zyz8fDdw1m5fhYoia1MKyEXScxotM25InCxQOnKae9IHCAh14C3UiptXoytzFewqtdOLZKZHPrhGVlcjP26aqnoGoFaUG5oKPZ70njGuQW/xxREbLdQYNahn9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722229692; c=relaxed/simple; bh=jwZkMT9G4RCOFzaAAkLP3wXhIF3ZBq28Z5dANy2GjUI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=YfnAYpeFuwo5u6Fa4TeJ+s6PnuCfE3NIImGtx9EO48kVox4QkIIfDhzBUjmBtbajUA/6NOSzgRlxq3sVotdYLMByAX16A/Mw5yI78Quc0ZhGnqBHR/YDZU1zZt5JdQOCFscry+35qwRX8fGfkH9KNfNsJYVLKFY2zh0Vwn6SQX0= 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.18.1.2/8.18.1.2) with ESMTP id 46T3HCqj029586; Mon, 29 Jul 2024 05:08:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=zf8ilEC6QkrE5 1wyey7YNnqnc2wLXHFLgqQhOoyteMU=; b=BrSCvPrjyQo/p1MgyBfp3Paez+tVQ Z/cFpLKLWTw4KZA36pdP8fJk7SVhZnujnPtugL8TcmHwkuiTns5mHq8kSSd+EyY0 KNNAE1ksZs+Adgf1GV36hIKMC/A6bYtKSiRN04yDDD0xZOEWWtnCEt21fm16OddX K3AVDXbcRkj2JAY1mS7mcD+R02fRN12JYc9QgaqQg1f0j71nUBbagO4JQd1izV/w WSLFNiqe//kePepmip1YjWv8nbiDyXdX8m0xHoBH472PvEyD1LBOglOzK2o+Njng tVpnSIIlnbq3RowmeUrofeJK+XV6sxbCRklgzJ55mls4yhYWu4rizobOg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40n34etvmq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Jul 2024 05:08:08 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46T55wch011856; Mon, 29 Jul 2024 05:08:08 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40n34etvmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Jul 2024 05:08:08 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46T1CBWY007470; Mon, 29 Jul 2024 05:08:07 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 40nb7tw4sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Jul 2024 05:08:07 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46T581IV44433862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Jul 2024 05:08:03 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C12982005A; Mon, 29 Jul 2024 05:08:01 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C382120040; Mon, 29 Jul 2024 05:08:00 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 29 Jul 2024 05:08:00 +0000 (GMT) From: Jiufu Guo To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, guojiufu@linux.ibm.com Subject: [PATCH V7 3/3] slight tune heuristic min_insns_constant_in_pool Date: Mon, 29 Jul 2024 13:07:57 +0800 Message-Id: <20240729050757.2500551-3-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240729050757.2500551-1-guojiufu@linux.ibm.com> References: <20240729050757.2500551-1-guojiufu@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Kw2xpgJPnY3TAOfRZX8y_FRcufdFBBAs X-Proofpoint-GUID: rZYA8rqlUfssDEKKo4LzEiV2Q18LbROS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-29_03,2024-07-26_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2407290032 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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, The default rs6000_min_insns_constant_in_pool is 2, which would suitable for a few cases. While for different targets, we can tune this threshold slightly. For example, 'pld' could load a constant value from memory as faster as building a constant by one instruction, and faster than build a constant through two instructions. This patch tune the parameter rs6000_min_insns_constant_in_pool for TARGET_PREFIXED and TARGET_32BIT. Bootstrap and regtest pass on ppc64 and ppc64le. Is this patch ok for trunk? BR, Jeff(Jiufu) Guo gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_option_override_internal): Tune rs6000_min_insns_constant_in_pool. gcc/testsuite/ChangeLog: * gcc.target/powerpc/const-build-1.c: Keep original test point by using rs6000_min_insns_constant_in_pool. * gcc.target/powerpc/const-build.c: Likewise. --- gcc/config/rs6000/rs6000.cc | 15 +++++++++++++++ gcc/testsuite/gcc.target/powerpc/const-build-1.c | 2 +- gcc/testsuite/gcc.target/powerpc/const-build.c | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index c785fb20b1b..632760dc814 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -4847,6 +4847,21 @@ rs6000_option_override_internal (bool global_init_p) warning (0, "%qs is deprecated and not recommended in any circumstances", "-mno-speculate-indirect-jumps"); + /* Set the threshold for how complicated constant should be put + into constant pool. */ + if (!OPTION_SET_P (rs6000_min_insns_constant_in_pool)) + { + /* one insn could load for the constant: pld 3, .LC1@pcrel + ld 0,.LC1@toc(2). */ + if (TARGET_PREFIXED || (TARGET_64BIT && TARGET_CMODEL == CMODEL_SMALL)) + rs6000_min_insns_constant_in_pool = 1; + + /* Consider address addjust, slight increase the threshold: + add 30,0,30; lwz 9,.LC1-.LCTOC1(30); ld 9,0(9); or + lis 9,.LC0@ha; la 9,.LC0@l(9); ld 9,0(9)*/ + else if (TARGET_32BIT && flag_pic != 1) + rs6000_min_insns_constant_in_pool = 3; + } return ret; } diff --git a/gcc/testsuite/gcc.target/powerpc/const-build-1.c b/gcc/testsuite/gcc.target/powerpc/const-build-1.c index 7e35f8c507f..e7061709fea 100644 --- a/gcc/testsuite/gcc.target/powerpc/const-build-1.c +++ b/gcc/testsuite/gcc.target/powerpc/const-build-1.c @@ -1,5 +1,5 @@ /* { dg-do compile { target lp64 } } */ -/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10 --param=rs6000-min-insns-constant-in-pool=2" } */ /* { dg-require-effective-target power10_ok } */ unsigned long long msk66() { return 0x6666666666666666ULL; } diff --git a/gcc/testsuite/gcc.target/powerpc/const-build.c b/gcc/testsuite/gcc.target/powerpc/const-build.c index 52941ca4c2f..31e1a611243 100644 --- a/gcc/testsuite/gcc.target/powerpc/const-build.c +++ b/gcc/testsuite/gcc.target/powerpc/const-build.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2 -save-temps" } */ +/* { dg-options "-O2 -save-temps --param=rs6000-min-insns-constant-in-pool=2" } */ /* { dg-require-effective-target has_arch_ppc64 } */ /* Verify that two instructions are successfully used to build constants.