From patchwork Fri Dec 15 08:52:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 179111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9132213dys; Fri, 15 Dec 2023 00:55:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVRqKFM9RGy+4+9Cn6hzjg6iwtQAKYMGNMYVKOR0YNxft2GqC2g3dngP+fsYQ7lHSw0qSd X-Received: by 2002:ae9:e00d:0:b0:77d:7446:d4df with SMTP id m13-20020ae9e00d000000b0077d7446d4dfmr13335247qkk.76.1702630546394; Fri, 15 Dec 2023 00:55:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702630546; cv=pass; d=google.com; s=arc-20160816; b=XDY1vuiuDgbvQjBAHnXX2hsyFn5+EMvWL5V+r2Dvd32Lh+P0VwBaNtYYdcto3bTr86 vJTLvLYlH74z6nWr+AAcEQn2cYy/uPtXOAFasgrHV8WK+bwj84UG1euu3NPs5O3rhrxr QJb9PAfLDk0fOJ0yZmhFpvPlIIeNuiyEPCrdFFaqwigcnwh5tK5bTfsqGYl/LhZgzepr bZwfT5zrawpBjzLInRIzb+EwJDtZlFLPgBez1TRLeE0Re027HlxO9Z8oJQdUDnzQmfUT X6suI3eWB2tKsZhe8FKIk9n99mXVncbZ8FOUL6uyWAR/93xeOmB7EeW4kQ69EzX1exUo yeAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :subject:from:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=gpt+o3y76asR43cP83n8f8SXxUYJHv68UNxzjrNV40E=; fh=uQV+D0ixYAxZIWyWEcgYIbLUvk77kXhBZ8te9MxENKc=; b=Gb5BzfLGzz3ZONgKjPiDWOrKKDjU5+/US/oYpORxzgTlcBJywPr5jbPupYeCdDK7ag 0HBsxj5LNhM2rIkdsc0rlOOSpPEsKPDP/mVfhNy9oqFlFjkMgt+5BfSxAwnN40+7NG03 xzNHhJwR7G3ii86PxxdTzOOoVDRKantg46S6UO5LweO8EmIG2VKmU7GDR/CubCI6OFPZ k+7kwWz7BjHuc/1uIRGS63JIta8ABubgK7si8n+VFh0Ruqop8ex/wv4l0jQn4/FDGPYt bresJRx621wmqPszU2lE5UDVUCrtRGhxe1B8sYsik4kg2Jg719ZIRkB4GdOSS4v/FjN9 PvqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GckprgaX; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bl19-20020a05620a1a9300b0077f5e12ded1si15640103qkb.618.2023.12.15.00.55.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:55:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GckprgaX; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22D0B384DB69 for ; Fri, 15 Dec 2023 08:55:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 85F3E3860763 for ; Fri, 15 Dec 2023 08:55:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85F3E3860763 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 85F3E3860763 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702630520; cv=none; b=UY4ynaDMnTSRDO/pVz1+DfhCCztkooZ9QEXW3S0uMnZXfAzunnbfHPrXkYHOA/b7Subbhon/JZzPFkU0XCzhRhMeZprXRz8LChvj5TTgf8szFDSF6yXRx6KlvuGSc5VVQYSSQIweRFxyXnDydqAempjYy3OWAo2kEMOUn1cNXcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702630520; c=relaxed/simple; bh=XeTrRnWErVUJtV+hdqfMykWxWZ1Hv4KbZQ2JQM9MB54=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=d3RfcmXEo8mrVouHDTfsmbY/Xbfs2O5P2q9CiH6XRUoFG56O5TAkG1P0B++fTQAdefoAQ2aCSQjY5WlOc097LjsrExsE5fkeyotR++1WeGuCt90w97dg9Gtg/rZzVvWgfSR+WZhLoVlIYQzNwmu/c3vXTRVfHg7+fzUSgd9Wwqg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BF7HlAE010659; Fri, 15 Dec 2023 08:55:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : from : subject : cc : content-type : content-transfer-encoding; s=pp1; bh=gpt+o3y76asR43cP83n8f8SXxUYJHv68UNxzjrNV40E=; b=GckprgaXMJWBSDMH7tTM+x28uPqJM/zFJawVyBpMSe7Jw5Y8iAxMUU9t3r4fPz9GvdH9 Zc7h1bXHYB1koQKrDp/h7GAnvCzEswmIRmNfdpeefn1DiLe9amBoKh8ePRPfLYOakWtm GIoGPAJ8fE0IuZwgrjwYtmG5wTwcz9ItdJQm+hhrcScmTsEPG6JxCdcF0r3SycsAyJnp u/pHtL/OTKv/scYl6mn6uylbVy3w0lG4cTSwId1S6BacPqNcRADLusFSNcF5bZbC6HRD EABee2butQnNQfjfpKUezuAx4WZvOHSGEPz0LiLEh6MMtiH50B7FDMJ75pR8TZYlTKuk 0g== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v0j9d264q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 08:55:14 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BF5u25H004216; Fri, 15 Dec 2023 08:52:08 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uw4skxgcj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 08:52:08 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BF8q6o938273694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Dec 2023 08:52:06 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EE892004B; Fri, 15 Dec 2023 08:52:06 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4515020040; Fri, 15 Dec 2023 08:52:03 +0000 (GMT) Received: from [9.177.65.75] (unknown [9.177.65.75]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 Dec 2023 08:52:02 +0000 (GMT) Message-ID: <834db636-da81-ded9-3385-ae65a4cb7c91@linux.ibm.com> Date: Fri, 15 Dec 2023 16:52:01 +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 Content-Language: en-US To: GCC Patches From: "Kewen.Lin" Subject: [PATCH] sel-sched: Verify change before replacing dest in EXPR_INSN_RTX [PR112995] Cc: Andrey Belevantsev , Alexander Monakov , Peter Bergner , Segher Boessenkool X-TM-AS-GCONF: 00 X-Proofpoint-GUID: uokjPdFG-BJzEEN3jb3HruVQLA88jlTr X-Proofpoint-ORIG-GUID: uokjPdFG-BJzEEN3jb3HruVQLA88jlTr 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-15_04,2023-12-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=824 impostorscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312150058 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785337527542563576 X-GMAIL-MSGID: 1785337527542563576 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. --- gcc/sel-sched.cc | 10 +++++++++- gcc/testsuite/gcc.target/powerpc/pr112995.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr112995.c -- 2.39.3 diff --git a/gcc/sel-sched.cc b/gcc/sel-sched.cc index 1925f4a9461..a35b5e16c91 100644 --- a/gcc/sel-sched.cc +++ b/gcc/sel-sched.cc @@ -1614,7 +1614,15 @@ try_replace_dest_reg (ilist_t orig_insns, rtx best_reg, expr_t expr) /* Make sure that EXPR has the right destination register. */ if (expr_dest_regno (expr) != REGNO (best_reg)) - replace_dest_with_reg_in_expr (expr, best_reg); + { + rtx_insn *vinsn = EXPR_INSN_RTX (expr); + validate_change (vinsn, &SET_DEST (PATTERN (vinsn)), best_reg, 1); + bool res = verify_changes (0); + cancel_changes (0); + if (!res) + return false; + replace_dest_with_reg_in_expr (expr, best_reg); + } else EXPR_TARGET_AVAILABLE (expr) = 1; diff --git a/gcc/testsuite/gcc.target/powerpc/pr112995.c b/gcc/testsuite/gcc.target/powerpc/pr112995.c new file mode 100644 index 00000000000..4adcb5f3851 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr112995.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target float128 } */ +/* { dg-options "-O2 -mdejagnu-cpu=power9 -fselective-scheduling2" } */ + +/* Verify there is no ICE. */ + +int a[10]; +int b(_Float128 e) { + int c; + _Float128 d; + c = e; + d = c; + d = a[c] + d; + return d; +}