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 D762E3858404 for ; Thu, 21 Dec 2023 05:50:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D762E3858404 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 D762E3858404 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=1703137822; cv=none; b=xPDdEqJe/kxOvLC/cz6vyKK0xuDJQOKBmtWXQPrIVi2LybPfCSrMo6uGgtK8B/mhftpzF5fZ9of6Xv/5qeewZBay9HpiVXq2SouMOGL+KIiNxJa1ygFL5nzWFsaZnyOW48RWVpGPnu/AmSaq+71igrRJUd3Rlfb59CNRc1JyTX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703137822; c=relaxed/simple; bh=z4q1M7MJAvkQGD2RLqwBfh1PTEwEZC34YdhZ8Y7zE4g=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ZgK1/H2d5DNM2lTaWCTTCa9qZQjXFkWnHlFeSfDsi5H9PtAnFOGeEllbZueZcoJLFlU4kwfG3s8vKP2VurXGRZMYjc+7SLbLie7CbqYh9fijE7vWx2+Om7WwP9xn3duF15Hxbm3l7pTH5zUYr/54T+6NtVmDWRMFlrqAGBNQEUo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BL2ptCU030862; Thu, 21 Dec 2023 05:50:19 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=X6P92x09Sr8XL5Ggzie0kG3B9WLsy0vwyUL4tv0uFYs=; b=U29zEOFoO+/Mg4f2hfNZBgu1ZTsYURyWyoyMERqzZqWp2iErqbRfXVIXMaOICxmEokoS 9A0AT0IQHNE1thrUDKmoqxBfADudvvfNessVv12SCINeJ7HFGxDSNKCTBnMuO093L++o HgDe36DGw1PpyW2+Mql6kvoKNarPr8mzxo/jP5vBa2tlRVKXZbV7C1Z0q1vKzR9340tD +6MmKaz5+mN4oep7x6tLBBaeo9SdSGBIjFUX5UY3TWVPB8y59VvQH1mQlTYplwTjapIM Lj/Jtw71VbtODB4Nwn85hOgI4aunsNWa232ZLUZaYW9nPH3khiHhZ9zg3v/56CBC3i/V vw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v4cxy5n3e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Dec 2023 05:50:19 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BL5oIsE029839; Thu, 21 Dec 2023 05:50:18 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v4cxy5kd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Dec 2023 05:50:17 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BL5NIGj004798; Thu, 21 Dec 2023 05:45:58 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3v1pm038c5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Dec 2023 05:45:58 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BL5ju0P43188622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Dec 2023 05:45:56 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C57A20040; Thu, 21 Dec 2023 05:45:56 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C29E2004B; Thu, 21 Dec 2023 05:45:54 +0000 (GMT) Received: from [9.197.228.79] (unknown [9.197.228.79]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 Dec 2023 05:45:53 +0000 (GMT) Message-ID: <7cc52e02-e205-048a-a7f6-52f517113adc@linux.ibm.com> Date: Thu, 21 Dec 2023 13:45:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] sel-sched: Verify change before replacing dest in EXPR_INSN_RTX [PR112995] Content-Language: en-US To: Jeff Law Cc: Andrey Belevantsev , Alexander Monakov , Peter Bergner , Segher Boessenkool , GCC Patches References: <834db636-da81-ded9-3385-ae65a4cb7c91@linux.ibm.com> <54424e42-cc7e-4d8d-a6dd-4566acaebf09@gmail.com> From: "Kewen.Lin" In-Reply-To: <54424e42-cc7e-4d8d-a6dd-4566acaebf09@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1tnH05OGMQLIHgYm2mYKdzJGPG1LAfHt X-Proofpoint-ORIG-GUID: jXTO5rBPODsWAzBrgAS5YcFbjrHX5Mb8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-21_02,2023-12-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=951 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312210041 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,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 List-Id: Hi Jeff, on 2023/12/21 04:30, Jeff Law wrote: > > > On 12/15/23 01:52, Kewen.Lin wrote: >> Hi, >> >> PR112995 exposed one issue in current try_replace_dest_reg >> that the result rtx insn after replace_dest_with_reg_in_expr >> is probably unable to match any constraints.  Although there >> are some checks on the changes onto dest or src of orig_insn, >> none is performed on the EXPR_INSN_RTX. >> >> This patch is to add the check before actually replacing dest >> in expr with reg. >> >> Bootstrapped and regtested on x86_64-redhat-linux and >> powerpc64{,le}-linux-gnu. >> >> Is it ok for trunk? >> >> BR, >> Kewen >> ----- >>     PR rtl-optimization/112995 >> >> gcc/ChangeLog: >> >>     * sel-sched.cc (try_replace_dest_reg): Check the validity of the >>     replaced insn before actually replacing dest in expr. >> >> gcc/testsuite/ChangeLog: >> >>     * gcc.target/powerpc/pr112995.c: New test. > Setting aside whether or not we should just deprecate/remove sel-sched for now.... > > > > From the PR: >> with moving up, we have: >> >> (insn 46 0 0 (set (reg:DI 64 0 [135]) >>         (sign_extend:DI (reg/v:SI 64 0 [orig:119 c ] [119]))) 31 {extendsidi2} >>      (expr_list:REG_DEAD (reg/v:SI 9 9 [orig:119 c ] [119]) >>         (nil))) >> >> in try_replace_dest_reg, we updated the above EXPR_INSN_RTX to: >> >> (insn 48 0 0 (set (reg:DI 32 0) >>         (sign_extend:DI (reg/v:SI 64 0 [orig:119 c ] [119]))) 31 {extendsidi2} >>      (nil)) >> >> This doesn't match any constraint and it's an unexpected modification. > > > It would have been helpful to include that in the patch, along with the fact that (reg 32) and (reg 64) are FP and VREGs respectively.  That makes it clearer why the constraints might not match after the change. > Good idea! > OK for the trunk. Thanks for the review, as suggested I updated the commit log as below and committed it as r14-6768-g5fbc77726f68a3. ----- PR112995 exposed one issue in current try_replace_dest_reg that the result rtx insn after replace_dest_with_reg_in_expr is probably unable to match any constraints. Although there are some checks on the changes onto dest or src of orig_insn, none is performed on the EXPR_INSN_RTX. Initially we have: (insn 31 6 10 2 (set (reg/v:SI 9 9 [orig:119 c ] [119]) (reg/v:SI 64 0 [orig:119 c ] [119])) "test.i":5:5 555 {*movsi_internal1} ... ) ... (insn 25 10 27 2 (set (reg:DI 64 0 [135]) (sign_extend:DI (reg/v:SI 9 9 [orig:119 c ] [119]))) "test.i":6:5 31 {extendsidi2} ...) with moving up, we have: (insn 46 0 0 (set (reg:DI 64 0 [135]) (sign_extend:DI (reg/v:SI 64 0 [orig:119 c ] [119]))) 31 {extendsidi2} ...) in try_replace_dest_reg, we updated the above EXPR_INSN_RTX to: (insn 48 0 0 (set (reg:DI 32 0) (sign_extend:DI (reg/v:SI 64 0 [orig:119 c ] [119]))) 31 {extendsidi2} ...) The dest (reg 64) is a VR (also VSX REG), the updating makes it become to (reg 32) which is a FPR (also VSX REG), we have an alternative to match "VR,VR" but no one to match "FPR/VSX, VR/VSX", so it fails with ICE. This patch is to add the check before actually replacing dest in expr with reg. ----- BR, Kewen