Message ID | d5e32c35-254b-b6ef-9637-059c223a765c@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50B413891C1A for <patchwork@sourceware.org>; Thu, 13 Jan 2022 01:57:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50B413891C1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642039066; bh=I8CYe7EapqodfA2OrzM/xmWnD/xe4cRwM++BeJ/VRck=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=P3AN7Is8AiCpjB4xt1jFq1VHALzW7ZTDaGqFSz27+h0gnGrInkxS28EF80NoNENGy KI7h6W2tf08GE9CsXozuMofDm7na0F1+5R+e4CakPv45YM6mbOLL1pBvxoEgrDWzDu 4npAYvzDkkWY0j2FNs5xVSRo1tAxthe3f7RYK95o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 1B8733891C02 for <gcc-patches@gcc.gnu.org>; Thu, 13 Jan 2022 01:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B8733891C02 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20D1qvKr023483; Thu, 13 Jan 2022 01:56:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3djat500xn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 01:56:01 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20D1qvEu023469; Thu, 13 Jan 2022 01:56:00 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 3djat500xd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 01:56:00 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 20D1qAIq020520; Thu, 13 Jan 2022 01:55:58 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 3df28aeeyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 01:55:58 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20D1tu0g38535440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jan 2022 01:55:56 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7136711C058; Thu, 13 Jan 2022 01:55:56 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC38211C04A; Thu, 13 Jan 2022 01:55:54 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.197.238.107]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 13 Jan 2022 01:55:54 +0000 (GMT) To: GCC Patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] rs6000: Fix constraint v with rs6000_constraints[RS6000_CONSTRAINT_v] Message-ID: <d5e32c35-254b-b6ef-9637-059c223a765c@linux.ibm.com> Date: Thu, 13 Jan 2022 09:55:52 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=gbk Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sAVBWvq6QEVl81Snzqb1r8vzWojripbv X-Proofpoint-ORIG-GUID: D_DBBf5h2Mg6laTdRE_fufEYWsL1nh3Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-12_08,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201130004 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: "Kewen.Lin via Gcc-patches" <gcc-patches@gcc.gnu.org> Reply-To: "Kewen.Lin" <linkw@linux.ibm.com> Cc: Bill Schmidt <wschmidt@linux.ibm.com>, David Edelsohn <dje.gcc@gmail.com>, Segher Boessenkool <segher@kernel.crashing.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
rs6000: Fix constraint v with rs6000_constraints[RS6000_CONSTRAINT_v]
|
|
Commit Message
Kewen.Lin
Jan. 13, 2022, 1:55 a.m. UTC
Hi, This patch is to fix register constraint v with rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, just like some other existing register constraints with RS6000_CONSTRAINT_*. I happened to see this and hope it's not intentional and just got neglected. Bootstrapped and regtested on powerpc64le-linux-gnu P9 and powerpc64-linux-gnu P8. Is it ok for trunk? BR, Kewen ----- gcc/ChangeLog: * config/rs6000/constraints.md (register constraint v): Use rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS. --- gcc/config/rs6000/constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.27.0
Comments
On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > > Hi, > > This patch is to fix register constraint v with > rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, > just like some other existing register constraints with > RS6000_CONSTRAINT_*. > > I happened to see this and hope it's not intentional and just > got neglected. > > Bootstrapped and regtested on powerpc64le-linux-gnu P9 and > powerpc64-linux-gnu P8. > > Is it ok for trunk? Why do you want to make this change? rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; but all of the patterns that use a "v" constraint are (or should be) protected by TARGET_ALTIVEC, or some final condition that only is active for TARGET_ALTIVEC. The other constraints are conditionally set because they can be used in a pattern with multiple alternatives where the pattern itself is active but some of the constraints correspond to NO_REGS when some instruction variants for VSX is not enabled. The change isn't wrong, but it doesn't correct a bug and provides no additional benefit nor clarty that I can see. Thanks, David
Hi David, on 2022/1/13 上午11:07, David Edelsohn wrote: > On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >> >> Hi, >> >> This patch is to fix register constraint v with >> rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, >> just like some other existing register constraints with >> RS6000_CONSTRAINT_*. >> >> I happened to see this and hope it's not intentional and just >> got neglected. >> >> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >> powerpc64-linux-gnu P8. >> >> Is it ok for trunk? > > Why do you want to make this change? > > rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; > > but all of the patterns that use a "v" constraint are (or should be) > protected by TARGET_ALTIVEC, or some final condition that only is > active for TARGET_ALTIVEC. The other constraints are conditionally > set because they can be used in a pattern with multiple alternatives > where the pattern itself is active but some of the constraints > correspond to NO_REGS when some instruction variants for VSX is not > enabled. > Good point! Thanks for the explanation. > The change isn't wrong, but it doesn't correct a bug and provides no > additional benefit nor clarty that I can see. > The original intention is to make it consistent with the other existing register constraints with RS6000_CONSTRAINT_*, otherwise it looks a bit weird (like was neglected). After you clarified above, RS6000_CONSTRAINT_v seems useless at all in the current framework. Do you prefer to remove it to avoid any confusions instead? BR, Kewen > Thanks, David >
On Wed, Jan 12, 2022 at 10:38 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > > Hi David, > > on 2022/1/13 上午11:07, David Edelsohn wrote: > > On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > >> > >> Hi, > >> > >> This patch is to fix register constraint v with > >> rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, > >> just like some other existing register constraints with > >> RS6000_CONSTRAINT_*. > >> > >> I happened to see this and hope it's not intentional and just > >> got neglected. > >> > >> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and > >> powerpc64-linux-gnu P8. > >> > >> Is it ok for trunk? > > > > Why do you want to make this change? > > > > rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; > > > > but all of the patterns that use a "v" constraint are (or should be) > > protected by TARGET_ALTIVEC, or some final condition that only is > > active for TARGET_ALTIVEC. The other constraints are conditionally > > set because they can be used in a pattern with multiple alternatives > > where the pattern itself is active but some of the constraints > > correspond to NO_REGS when some instruction variants for VSX is not > > enabled. > > > > Good point! Thanks for the explanation. > > > The change isn't wrong, but it doesn't correct a bug and provides no > > additional benefit nor clarty that I can see. > > > > The original intention is to make it consistent with the other existing > register constraints with RS6000_CONSTRAINT_*, otherwise it looks a bit > weird (like was neglected). After you clarified above, RS6000_CONSTRAINT_v > seems useless at all in the current framework. Do you prefer to remove > it to avoid any confusions instead? It's used in the reg_class, so there may be some heuristic in the GCC register allocator that cares about the number of registers available for the target. rs6000_constraints[RS6000_CONSTRAINT_v] is defined conditionally, so it seems best to leave it as is. Thanks, David
on 2022/1/13 上午11:44, David Edelsohn wrote: > On Wed, Jan 12, 2022 at 10:38 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >> >> Hi David, >> >> on 2022/1/13 上午11:07, David Edelsohn wrote: >>> On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >>>> >>>> Hi, >>>> >>>> This patch is to fix register constraint v with >>>> rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, >>>> just like some other existing register constraints with >>>> RS6000_CONSTRAINT_*. >>>> >>>> I happened to see this and hope it's not intentional and just >>>> got neglected. >>>> >>>> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >>>> powerpc64-linux-gnu P8. >>>> >>>> Is it ok for trunk? >>> >>> Why do you want to make this change? >>> >>> rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; >>> >>> but all of the patterns that use a "v" constraint are (or should be) >>> protected by TARGET_ALTIVEC, or some final condition that only is >>> active for TARGET_ALTIVEC. The other constraints are conditionally >>> set because they can be used in a pattern with multiple alternatives >>> where the pattern itself is active but some of the constraints >>> correspond to NO_REGS when some instruction variants for VSX is not >>> enabled. >>> >> >> Good point! Thanks for the explanation. >> >>> The change isn't wrong, but it doesn't correct a bug and provides no >>> additional benefit nor clarty that I can see. >>> >> >> The original intention is to make it consistent with the other existing >> register constraints with RS6000_CONSTRAINT_*, otherwise it looks a bit >> weird (like was neglected). After you clarified above, RS6000_CONSTRAINT_v >> seems useless at all in the current framework. Do you prefer to remove >> it to avoid any confusions instead? > > It's used in the reg_class, so there may be some heuristic in the GCC > register allocator that cares about the number of registers available > for the target. rs6000_constraints[RS6000_CONSTRAINT_v] is defined > conditionally, so it seems best to leave it as is. > I may miss something, but I didn't find it's used for the above purposes. If it's best to leave it as is, the proposed patch seems to offer better readability. BR, Kewen > Thanks, David >
on 2022/1/13 上午11:56, Kewen.Lin via Gcc-patches wrote: > on 2022/1/13 上午11:44, David Edelsohn wrote: >> On Wed, Jan 12, 2022 at 10:38 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >>> >>> Hi David, >>> >>> on 2022/1/13 上午11:07, David Edelsohn wrote: >>>> On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >>>>> >>>>> Hi, >>>>> >>>>> This patch is to fix register constraint v with >>>>> rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, >>>>> just like some other existing register constraints with >>>>> RS6000_CONSTRAINT_*. >>>>> >>>>> I happened to see this and hope it's not intentional and just >>>>> got neglected. >>>>> >>>>> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >>>>> powerpc64-linux-gnu P8. >>>>> >>>>> Is it ok for trunk? >>>> >>>> Why do you want to make this change? >>>> >>>> rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; >>>> >>>> but all of the patterns that use a "v" constraint are (or should be) >>>> protected by TARGET_ALTIVEC, or some final condition that only is >>>> active for TARGET_ALTIVEC. The other constraints are conditionally >>>> set because they can be used in a pattern with multiple alternatives >>>> where the pattern itself is active but some of the constraints >>>> correspond to NO_REGS when some instruction variants for VSX is not >>>> enabled. >>>> >>> >>> Good point! Thanks for the explanation. >>> >>>> The change isn't wrong, but it doesn't correct a bug and provides no >>>> additional benefit nor clarty that I can see. >>>> >>> >>> The original intention is to make it consistent with the other existing >>> register constraints with RS6000_CONSTRAINT_*, otherwise it looks a bit >>> weird (like was neglected). After you clarified above, RS6000_CONSTRAINT_v >>> seems useless at all in the current framework. Do you prefer to remove >>> it to avoid any confusions instead? >> >> It's used in the reg_class, so there may be some heuristic in the GCC >> register allocator that cares about the number of registers available >> for the target. rs6000_constraints[RS6000_CONSTRAINT_v] is defined >> conditionally, so it seems best to leave it as is. >> > > I may miss something, but I didn't find it's used for the above purposes. > If it's best to leave it as is, the proposed patch seems to offer better > readability. Two more inputs for maintainers' decision: 1) the original proposed patch fixed one "bug" that is: In function rs6000_debug_reg_global, it tries to print the register class for the register constraint: fprintf (stderr, "\n" "d reg_class = %s\n" "f reg_class = %s\n" "v reg_class = %s\n" "wa reg_class = %s\n" ... "\n", reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], ... It uses rs6000_constraints[RS6000_CONSTRAINT_v] which is conditionally set here: /* Add conditional constraints based on various options, to allow us to collapse multiple insn patterns. */ if (TARGET_ALTIVEC) rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; But the actual register class for register constraint is hardcoded as ALTIVEC_REGS rather than rs6000_constraints[RS6000_CONSTRAINT_v]. 2) Bootstrapped and tested one below patch to remove all the code using RS6000_CONSTRAINT_v on powerpc64le-linux-gnu P10 and P9, powerpc64-linux-gnu P8 and P7 with no regressions. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 37f07fe5358..3652629c5d0 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -2320,7 +2320,6 @@ rs6000_debug_reg_global (void) "\n" "d reg_class = %s\n" "f reg_class = %s\n" - "v reg_class = %s\n" "wa reg_class = %s\n" "we reg_class = %s\n" "wr reg_class = %s\n" @@ -2329,7 +2328,6 @@ rs6000_debug_reg_global (void) "\n", reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]], - reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_we]], reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wr]], @@ -2984,11 +2982,6 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) if (TARGET_VSX) rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS; - /* Add conditional constraints based on various options, to allow us to - collapse multiple insn patterns. */ - if (TARGET_ALTIVEC) - rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; - if (TARGET_POWERPC64) { rs6000_constraints[RS6000_CONSTRAINT_wr] = GENERAL_REGS; diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 4d2f88d4218..48323b80eee 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -1237,7 +1237,6 @@ extern enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER]; enum r6000_reg_class_enum { RS6000_CONSTRAINT_d, /* fpr registers for double values */ RS6000_CONSTRAINT_f, /* fpr registers for single values */ - RS6000_CONSTRAINT_v, /* Altivec registers */ RS6000_CONSTRAINT_wa, /* Any VSX register */ RS6000_CONSTRAINT_we, /* VSX register if ISA 3.0 vector. */ RS6000_CONSTRAINT_wr, /* GPR register if 64-bit */ BR, Kewen
On Thu, Jan 13, 2022 at 7:28 AM Kewen.Lin <linkw@linux.ibm.com> wrote: > > on 2022/1/13 上午11:56, Kewen.Lin via Gcc-patches wrote: > > on 2022/1/13 上午11:44, David Edelsohn wrote: > >> On Wed, Jan 12, 2022 at 10:38 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > >>> > >>> Hi David, > >>> > >>> on 2022/1/13 上午11:07, David Edelsohn wrote: > >>>> On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > >>>>> > >>>>> Hi, > >>>>> > >>>>> This patch is to fix register constraint v with > >>>>> rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, > >>>>> just like some other existing register constraints with > >>>>> RS6000_CONSTRAINT_*. > >>>>> > >>>>> I happened to see this and hope it's not intentional and just > >>>>> got neglected. > >>>>> > >>>>> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and > >>>>> powerpc64-linux-gnu P8. > >>>>> > >>>>> Is it ok for trunk? > >>>> > >>>> Why do you want to make this change? > >>>> > >>>> rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; > >>>> > >>>> but all of the patterns that use a "v" constraint are (or should be) > >>>> protected by TARGET_ALTIVEC, or some final condition that only is > >>>> active for TARGET_ALTIVEC. The other constraints are conditionally > >>>> set because they can be used in a pattern with multiple alternatives > >>>> where the pattern itself is active but some of the constraints > >>>> correspond to NO_REGS when some instruction variants for VSX is not > >>>> enabled. > >>>> > >>> > >>> Good point! Thanks for the explanation. > >>> > >>>> The change isn't wrong, but it doesn't correct a bug and provides no > >>>> additional benefit nor clarty that I can see. > >>>> > >>> > >>> The original intention is to make it consistent with the other existing > >>> register constraints with RS6000_CONSTRAINT_*, otherwise it looks a bit > >>> weird (like was neglected). After you clarified above, RS6000_CONSTRAINT_v > >>> seems useless at all in the current framework. Do you prefer to remove > >>> it to avoid any confusions instead? > >> > >> It's used in the reg_class, so there may be some heuristic in the GCC > >> register allocator that cares about the number of registers available > >> for the target. rs6000_constraints[RS6000_CONSTRAINT_v] is defined > >> conditionally, so it seems best to leave it as is. > >> > > > > I may miss something, but I didn't find it's used for the above purposes. > > If it's best to leave it as is, the proposed patch seems to offer better > > readability. > > Two more inputs for maintainers' decision: > > 1) the original proposed patch fixed one "bug" that is: > > In function rs6000_debug_reg_global, it tries to print the register class > for the register constraint: > > fprintf (stderr, > "\n" > "d reg_class = %s\n" > "f reg_class = %s\n" > "v reg_class = %s\n" > "wa reg_class = %s\n" > ... > "\n", > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], > ... > > It uses rs6000_constraints[RS6000_CONSTRAINT_v] which is conditionally > set here: > > /* Add conditional constraints based on various options, to allow us to > collapse multiple insn patterns. */ > if (TARGET_ALTIVEC) > rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; > > But the actual register class for register constraint is hardcoded as > ALTIVEC_REGS rather than rs6000_constraints[RS6000_CONSTRAINT_v]. I agree that the information is inaccurate, but it is informal debugging output. And if Altivec is disabled, the value of the constraint is irrelevant / garbage. > > 2) Bootstrapped and tested one below patch to remove all the code using > RS6000_CONSTRAINT_v on powerpc64le-linux-gnu P10 and P9, > powerpc64-linux-gnu P8 and P7 with no regressions. > > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > index 37f07fe5358..3652629c5d0 100644 > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -2320,7 +2320,6 @@ rs6000_debug_reg_global (void) > "\n" > "d reg_class = %s\n" > "f reg_class = %s\n" > - "v reg_class = %s\n" > "wa reg_class = %s\n" > "we reg_class = %s\n" > "wr reg_class = %s\n" > @@ -2329,7 +2328,6 @@ rs6000_debug_reg_global (void) > "\n", > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]], > - reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_we]], > reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wr]], > @@ -2984,11 +2982,6 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) > if (TARGET_VSX) > rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS; > > - /* Add conditional constraints based on various options, to allow us to > - collapse multiple insn patterns. */ > - if (TARGET_ALTIVEC) > - rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; > - > if (TARGET_POWERPC64) > { > rs6000_constraints[RS6000_CONSTRAINT_wr] = GENERAL_REGS; > diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h > index 4d2f88d4218..48323b80eee 100644 > --- a/gcc/config/rs6000/rs6000.h > +++ b/gcc/config/rs6000/rs6000.h > @@ -1237,7 +1237,6 @@ extern enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER]; > enum r6000_reg_class_enum { > RS6000_CONSTRAINT_d, /* fpr registers for double values */ > RS6000_CONSTRAINT_f, /* fpr registers for single values */ > - RS6000_CONSTRAINT_v, /* Altivec registers */ > RS6000_CONSTRAINT_wa, /* Any VSX register */ > RS6000_CONSTRAINT_we, /* VSX register if ISA 3.0 vector. */ > RS6000_CONSTRAINT_wr, /* GPR register if 64-bit */ I would prefer that we not make gratuitous changes to this code, but maybe Segher has a different opinion. Thanks, David
on 2022/1/14 上午12:31, David Edelsohn wrote: > On Thu, Jan 13, 2022 at 7:28 AM Kewen.Lin <linkw@linux.ibm.com> wrote: >> >> on 2022/1/13 上午11:56, Kewen.Lin via Gcc-patches wrote: >>> on 2022/1/13 上午11:44, David Edelsohn wrote: >>>> On Wed, Jan 12, 2022 at 10:38 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >>>>> >>>>> Hi David, >>>>> >>>>> on 2022/1/13 上午11:07, David Edelsohn wrote: >>>>>> On Wed, Jan 12, 2022 at 8:56 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> This patch is to fix register constraint v with >>>>>>> rs6000_constraints[RS6000_CONSTRAINT_v] instead of ALTIVEC_REGS, >>>>>>> just like some other existing register constraints with >>>>>>> RS6000_CONSTRAINT_*. >>>>>>> >>>>>>> I happened to see this and hope it's not intentional and just >>>>>>> got neglected. >>>>>>> >>>>>>> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >>>>>>> powerpc64-linux-gnu P8. >>>>>>> >>>>>>> Is it ok for trunk? >>>>>> >>>>>> Why do you want to make this change? >>>>>> >>>>>> rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; >>>>>> >>>>>> but all of the patterns that use a "v" constraint are (or should be) >>>>>> protected by TARGET_ALTIVEC, or some final condition that only is >>>>>> active for TARGET_ALTIVEC. The other constraints are conditionally >>>>>> set because they can be used in a pattern with multiple alternatives >>>>>> where the pattern itself is active but some of the constraints >>>>>> correspond to NO_REGS when some instruction variants for VSX is not >>>>>> enabled. >>>>>> >>>>> >>>>> Good point! Thanks for the explanation. >>>>> >>>>>> The change isn't wrong, but it doesn't correct a bug and provides no >>>>>> additional benefit nor clarty that I can see. >>>>>> >>>>> >>>>> The original intention is to make it consistent with the other existing >>>>> register constraints with RS6000_CONSTRAINT_*, otherwise it looks a bit >>>>> weird (like was neglected). After you clarified above, RS6000_CONSTRAINT_v >>>>> seems useless at all in the current framework. Do you prefer to remove >>>>> it to avoid any confusions instead? >>>> >>>> It's used in the reg_class, so there may be some heuristic in the GCC >>>> register allocator that cares about the number of registers available >>>> for the target. rs6000_constraints[RS6000_CONSTRAINT_v] is defined >>>> conditionally, so it seems best to leave it as is. >>>> >>> >>> I may miss something, but I didn't find it's used for the above purposes. >>> If it's best to leave it as is, the proposed patch seems to offer better >>> readability. >> >> Two more inputs for maintainers' decision: >> >> 1) the original proposed patch fixed one "bug" that is: >> >> In function rs6000_debug_reg_global, it tries to print the register class >> for the register constraint: >> >> fprintf (stderr, >> "\n" >> "d reg_class = %s\n" >> "f reg_class = %s\n" >> "v reg_class = %s\n" >> "wa reg_class = %s\n" >> ... >> "\n", >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], >> ... >> >> It uses rs6000_constraints[RS6000_CONSTRAINT_v] which is conditionally >> set here: >> >> /* Add conditional constraints based on various options, to allow us to >> collapse multiple insn patterns. */ >> if (TARGET_ALTIVEC) >> rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; >> >> But the actual register class for register constraint is hardcoded as >> ALTIVEC_REGS rather than rs6000_constraints[RS6000_CONSTRAINT_v]. > > I agree that the information is inaccurate, but it is informal > debugging output. And if Altivec is disabled, the value of the > constraint is irrelevant / garbage. > Yeah, but IMHO it still can confuse new comers at first glance. >> >> 2) Bootstrapped and tested one below patch to remove all the code using >> RS6000_CONSTRAINT_v on powerpc64le-linux-gnu P10 and P9, >> powerpc64-linux-gnu P8 and P7 with no regressions. >> >> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c >> index 37f07fe5358..3652629c5d0 100644 >> --- a/gcc/config/rs6000/rs6000.c >> +++ b/gcc/config/rs6000/rs6000.c >> @@ -2320,7 +2320,6 @@ rs6000_debug_reg_global (void) >> "\n" >> "d reg_class = %s\n" >> "f reg_class = %s\n" >> - "v reg_class = %s\n" >> "wa reg_class = %s\n" >> "we reg_class = %s\n" >> "wr reg_class = %s\n" >> @@ -2329,7 +2328,6 @@ rs6000_debug_reg_global (void) >> "\n", >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]], >> - reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_we]], >> reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wr]], >> @@ -2984,11 +2982,6 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) >> if (TARGET_VSX) >> rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS; >> >> - /* Add conditional constraints based on various options, to allow us to >> - collapse multiple insn patterns. */ >> - if (TARGET_ALTIVEC) >> - rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; >> - >> if (TARGET_POWERPC64) >> { >> rs6000_constraints[RS6000_CONSTRAINT_wr] = GENERAL_REGS; >> diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h >> index 4d2f88d4218..48323b80eee 100644 >> --- a/gcc/config/rs6000/rs6000.h >> +++ b/gcc/config/rs6000/rs6000.h >> @@ -1237,7 +1237,6 @@ extern enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER]; >> enum r6000_reg_class_enum { >> RS6000_CONSTRAINT_d, /* fpr registers for double values */ >> RS6000_CONSTRAINT_f, /* fpr registers for single values */ >> - RS6000_CONSTRAINT_v, /* Altivec registers */ >> RS6000_CONSTRAINT_wa, /* Any VSX register */ >> RS6000_CONSTRAINT_we, /* VSX register if ISA 3.0 vector. */ >> RS6000_CONSTRAINT_wr, /* GPR register if 64-bit */ > > I would prefer that we not make gratuitous changes to this code, but > maybe Segher has a different opinion. > Thanks David for the comments! Hi Segher, what's your preference on this? BR, Kewen
Hi! On Wed, Jan 26, 2022 at 10:26:45AM +0800, Kewen.Lin wrote: > on 2022/1/14 上午12:31, David Edelsohn wrote: > Yeah, but IMHO it still can confuse new comers at first glance. Yes, or at least cause to read (well, grep) the whole backend and scratch heads. > >> 2) Bootstrapped and tested one below patch to remove all the code using > >> RS6000_CONSTRAINT_v on powerpc64le-linux-gnu P10 and P9, > >> powerpc64-linux-gnu P8 and P7 with no regressions. > > I would prefer that we not make gratuitous changes to this code, but > > maybe Segher has a different opinion. > > Thanks David for the comments! > > Hi Segher, what's your preference on this? I like your original patch better. But for stage 1, sorry. Indeed using ALTIVEC_REGS directly in the define_regiater_constraint works fine, but it isn't as clear as it could be that is correct. Segher
on 2022/1/27 上午1:57, Segher Boessenkool wrote: > Hi! > > On Wed, Jan 26, 2022 at 10:26:45AM +0800, Kewen.Lin wrote: >> on 2022/1/14 上午12:31, David Edelsohn wrote: >> Yeah, but IMHO it still can confuse new comers at first glance. > > Yes, or at least cause to read (well, grep) the whole backend and > scratch heads. > >>>> 2) Bootstrapped and tested one below patch to remove all the code using >>>> RS6000_CONSTRAINT_v on powerpc64le-linux-gnu P10 and P9, >>>> powerpc64-linux-gnu P8 and P7 with no regressions. > >>> I would prefer that we not make gratuitous changes to this code, but >>> maybe Segher has a different opinion. >> >> Thanks David for the comments! >> >> Hi Segher, what's your preference on this? > > I like your original patch better. But for stage 1, sorry. > Thanks Segher! Is it ok to commit it then? Or I'll repost this once next stage1 starts. BR, Kewen > Indeed using ALTIVEC_REGS directly in the define_regiater_constraint > works fine, but it isn't as clear as it could be that is correct. > > > Segher >
On Thu, Jan 27, 2022 at 07:24:53PM +0800, Kewen.Lin wrote: > on 2022/1/27 上午1:57, Segher Boessenkool wrote: > > I like your original patch better. But for stage 1, sorry. > > Thanks Segher! Is it ok to commit it then? Or I'll repost this once > next stage1 starts. Either is fine in this case. Segher
on 2022/1/27 20:51, Segher Boessenkool wrote: > On Thu, Jan 27, 2022 at 07:24:53PM +0800, Kewen.Lin wrote: >> on 2022/1/27 上午1:57, Segher Boessenkool wrote: >>> I like your original patch better. But for stage 1, sorry. >> >> Thanks Segher! Is it ok to commit it then? Or I'll repost this once >> next stage1 starts. > > Either is fine in this case. > Thanks! Re-tested and pushed in r13-283. BR, Kewen
diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md index a4b05837fa6..c01dcbbc3a3 100644 --- a/gcc/config/rs6000/constraints.md +++ b/gcc/config/rs6000/constraints.md @@ -37,7 +37,7 @@ (define_register_constraint "d" "rs6000_constraints[RS6000_CONSTRAINT_d]" historically @code{f} was for single-precision and @code{d} was for double-precision floating point.") -(define_register_constraint "v" "ALTIVEC_REGS" +(define_register_constraint "v" "rs6000_constraints[RS6000_CONSTRAINT_v]" "An Altivec vector register (VR), @code{v0}@dots{}@code{v31}.") (define_register_constraint "wa" "rs6000_constraints[RS6000_CONSTRAINT_wa]"