From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 775803858D33 for ; Thu, 6 Jul 2023 18:41:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 775803858D33 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 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 366Icq40008954; Thu, 6 Jul 2023 18:41:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=tnXOIfBWnet9yenwQku8n9Xk20cwGCZNHcEiKcQyNYI=; b=nQ9ALfqrnit+NqqMd7uNlhjhF2QGXWSCjySgO9/U25P5mPP0GgPdBYNGHP3/3FqivbCP l6OSiLQg6E+DmWrCS69fQvehmi62KP3Bf6KEx3qvSVd9cVbla2/sdm0AQYhKrHq242Lb x1mZZtfVUDxTw7dp3U24dBR3DCQdpXaazjlWLt+ZVMn6MelqXRe5fBbLq1CYo6OLwr8S A3zmjVIXobrmFyPwiOra6oMAZfRJZp9m5N1KMdJPrAoUUCz4NPVNjBIR5u+Cz+V3jpZA tj2C7QEitPuHnPSwdPw96SDxVEevbMGaN/cBG8j9ekq+XvhDSfdHW42xPwXvGNnqP2WH wA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rp2rq0fpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 18:41:35 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 366IdaSY011675; Thu, 6 Jul 2023 18:41:35 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rp2rq0fnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 18:41:35 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 366Fk98W001938; Thu, 6 Jul 2023 18:41:34 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([9.208.130.99]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3rjbs61yud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 18:41:34 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 366IfXIi38142526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Jul 2023 18:41:33 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F06C58055; Thu, 6 Jul 2023 18:41:33 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F2455805D; Thu, 6 Jul 2023 18:41:33 +0000 (GMT) Received: from [9.61.25.68] (unknown [9.61.25.68]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 6 Jul 2023 18:41:32 +0000 (GMT) Message-ID: <64addcb2-4370-6885-a08e-e93e2b7e3ede@linux.ibm.com> Date: Thu, 6 Jul 2023 13:41:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] rs6000: Change GPR2 to volatile & non-fixed register for function that does not use TOC [PR110320] Content-Language: en-US To: "Kewen.Lin" , P Jeevitha Cc: Segher Boessenkool , gcc-patches@gcc.gnu.org, David Edelsohn References: From: Peter Bergner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SghBHm40BsyIOj6xgRNLddm5tVoxrc3I X-Proofpoint-ORIG-GUID: YSSht0_9BnjiIvVMDRlu7NzYAxzrhnMc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-06_13,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 spamscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxlogscore=853 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307060165 X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 6/28/23 3:07 AM, Kewen.Lin wrote: > I think the reason why we need to check common_deferred_options is at this time > we can't distinguish the fixed_regs[2] is from the initialization or command line > user explicit specification. But could we just update the FIXED_REGISTERS without > FIXED_R2 and set FIXED_R2 when it's needed in this function instead? Then I'd > expect that when we find fixed_regs[2] is set at the beginning of this function, it > would mean users specify it explicitly and then we don't need this option checking? Correct, rs6000_conditional_register_usage() is called after the handling of the -ffixed-* options, so looking at fixed_regs[2] cannot tell us whether the user used the -ffixed-r2 option or not if we initialize the FIXED_REGISTERS[2] slot to 1. I think we went this route for two reasons: 1) We don't have to worry about anyone in the future adding more uses of FIXED_REGISTERS and needing to update the value depending on ABI, options, etc. 2) The options in common_deferred_options are "rare" options, so the common case is that common_deferred_options will be NULL and we'll never drop into that section. I believe the untested patch below should also work, without having to scan the (uncommonly used) options. Jeevitha, can you bootstrap and regtest the patch below? > Besides, IMHO we need a corresponding test case to cover this -ffixed-r2 handling. Good idea. I think we can duplicate the pr110320_2.c test case, replacing the -mno-pcrel option with -ffixed-r2. Jeevitha, can you give that a try? >> +/* { dg-require-effective-target power10_ok } */ >> +/* { dg-require-effective-target powerpc_pcrel } */ > > Do we have some environment combination which supports powerpc_pcrel but not > power10_ok? I'd expect that only powerpc_pcrel is enough. I think I agree testing for powerpc_pcrel should be enough. Peter diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index d197c3f3289..7c356a73ac6 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -10160,9 +10160,13 @@ rs6000_conditional_register_usage (void) for (i = 32; i < 64; i++) fixed_regs[i] = call_used_regs[i] = 1; + /* For non PC-relative code, GPR2 is unavailable for register allocation. */ + if (FIXED_R2 && !rs6000_pcrel_p ()) + fixed_regs[2] = 1; + /* The TOC register is not killed across calls in a way that is visible to the compiler. */ - if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) + if (fixed_regs[2] && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)) call_used_regs[2] = 0; if (DEFAULT_ABI == ABI_V4 && flag_pic == 2) diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 3503614efbd..2a24fbdf9fd 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -812,7 +812,7 @@ enum data_align { align_abi, align_opt, align_both }; #define FIXED_REGISTERS \ {/* GPRs */ \ - 0, 1, FIXED_R2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_R13, 0, 0, \ + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_R13, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ /* FPRs */ \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \