From patchwork Tue Jul 19 14:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 60 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2490543eik; Tue, 19 Jul 2022 07:36:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v/iPFS9F24+klXzFPesjD61wveXFIav1FGqHK7JJuXBXBCD8MC+UTWCSbQoHg5buCPf6ro X-Received: by 2002:a05:6402:3707:b0:437:61f9:57a9 with SMTP id ek7-20020a056402370700b0043761f957a9mr34153120edb.1.1658241409732; Tue, 19 Jul 2022 07:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658241409; cv=none; d=google.com; s=arc-20160816; b=soTVX9FjJJrDZ9PsNUTWbSGKpeDijFH1rC6Zc8tuQhh/JlhD03HplfzU17HkmNHRo9 fbN1SLJ1wAUCz2+fN8EqOVI/n9dhUdI4j+Lp1v1CaDeU9FwOzpBysK0GmDloZRmpzD9f ovMhRCNGz94+2ZmoaT9Oi8f8I9OwHS9nY4OntnO031iiMdME7EOA55v7sH30ya9DqU5Y 83Ax3oaUv0sv7KlR0IPYB1c2cQSwc9gZOIn51Jc/8qd/vgZdzAuKxhpH0+zIMsPJ0T06 IATtvsH5DFyN8+PX0x46WmvgM3T8hti5tyRC9n0LZakVj0lndteyRFYQJ2TFd2Uzmv9T EXWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=y11ALjNtWmSAPCml64zIAIz55wy8SfmkBAGobwSMY8U=; b=ejNVTjyuQ6+0wGrixvCtfF293OlZ3ees6bNkgRgE8fMDY7hSPGs2TJXhhLM/GzYD+x GM8D7arKHqFDVT3EDPIQqxIfbzVS8c8MHzx8t5Emo/l5WGoHAEKgh33dl6ZUcHEHSQnv XN2R3Slp5RaNJ03B6kS9R1WUwUQCKX5AZgHwxROzoeXeepAVAfoWHVo7QQszVCA3NadJ hIk6l6oK3G7MB+arlR1AGE7I/mKfMmAQW3NYCsiokV4ikC3CL6oi2VrHUtGNR9h3dDas jmDjGHrbpDXlu1tmxCc4pEfojMQqjLsK/uRfjPhCqME9h2vamEbvAhA71oafewIPj8RV oIDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WoRHKx6Y; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e14-20020a056402190e00b0043a7e704d2asi22441102edz.365.2022.07.19.07.36.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 07:36:49 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=WoRHKx6Y; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C4A0B3857809 for ; Tue, 19 Jul 2022 14:36:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4A0B3857809 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658241408; bh=y11ALjNtWmSAPCml64zIAIz55wy8SfmkBAGobwSMY8U=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=WoRHKx6YFh515yae2gIgWcJy3s067vFr6zCt3poqQvJN2jEpbGItg0VLAYbJqQpZt PR+YBFzo7xhLkU+UvqnYCYq13Z48fw0MYKlTLkyUm6pC6sEz9+c0GTBmEMV7DtpFbU y2SEAz0C4p/TRTG7ebN6plT9N61u/PTnVb3lA+9I= 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 9E7B23858439; Tue, 19 Jul 2022 14:36:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9E7B23858439 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26JEIF1O017857; Tue, 19 Jul 2022 14:36:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hdx8frp2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Jul 2022 14:36:04 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26JEKHBw003944; Tue, 19 Jul 2022 14:36:02 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hdx8frnw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Jul 2022 14:36:02 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26JEKbY6002659; Tue, 19 Jul 2022 14:30:58 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 3hbmy8k7wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Jul 2022 14:30:58 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26JEUu4917105364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jul 2022 14:30:56 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 560C84C04E; Tue, 19 Jul 2022 14:30:56 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C8204C040; Tue, 19 Jul 2022 14:30:55 +0000 (GMT) Received: from pike.rch.stglabs.ibm.com (unknown [9.5.12.127]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 19 Jul 2022 14:30:55 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH V1] HIGH part of symbol ref is invalid for constant pool Date: Tue, 19 Jul 2022 22:30:54 +0800 Message-Id: <20220719143054.82832-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Ug7bTwbqYUzV6ofLbcPF1Wh8frDD5vU5 X-Proofpoint-ORIG-GUID: TzAZOyFRsI4RPhpEDyJXhZnwm9jFEZeu X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-19_02,2022-07-19_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207190061 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jiufu Guo via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jiufu Guo Cc: dje.gcc@gmail.com, segher@kernel.crashing.org, linkw@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1738792144672392213?= X-GMAIL-MSGID: =?utf-8?q?1738792144672392213?= Hi, In patch https://gcc.gnu.org/pipermail/gcc-patches/2022-July/597712.html, test case was not added. After more check, a testcase is added for it. The high part of the symbol address is invalid for the constant pool. In function rs6000_cannot_force_const_mem, we already return true for "HIGH with UNSPEC" rtx. Below are some examples also indicate the high part of a symbol_ref: (high:DI (const:DI (plus:DI (symbol_ref:DI ("xx") (const_int 12 [0xc]))))) (high:DI (symbol_ref:DI ("var_1")..))) This patch updates rs6000_cannot_force_const_mem to return true for rtx with HIGH code. Bootstrapped and regtested on ppc64le and ppc64. Is it ok for trunk? BR, Jeff(Jiufu) gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_cannot_force_const_mem): Return true for HIGH code rtx. gcc/testsuite/ChangeLog: * gcc.target/powerpc/constpoolcheck.c: New test. --- gcc/config/rs6000/rs6000.cc | 7 +++++-- gcc/testsuite/gcc.target/powerpc/constpoolcheck.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/constpoolcheck.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 0af2085adc0..d56832ebbfc 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -9704,8 +9704,11 @@ rs6000_init_stack_protect_guard (void) static bool rs6000_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x) { - if (GET_CODE (x) == HIGH - && GET_CODE (XEXP (x, 0)) == UNSPEC) + /* High part of a symbol ref/address can not be put into constant pool. e.g. + (high:DI (symbol_ref:DI ("var")..)) or + (high:DI (unspec:DI [(symbol_ref/u:DI ("*.LC0")..) + (high:DI (const:DI (plus:DI (symbol_ref:DI ("xx")) (const_int 12)))). */ + if (GET_CODE (x) == HIGH) return true; /* A TLS symbol in the TOC cannot contain a sum. */ diff --git a/gcc/testsuite/gcc.target/powerpc/constpoolcheck.c b/gcc/testsuite/gcc.target/powerpc/constpoolcheck.c new file mode 100644 index 00000000000..ed7a994827b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/constpoolcheck.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-O1 -mdejagnu-cpu=power10" } */ +/* (high:DI (symbol_ref:DI ("var_48")..))) should not cause ICE. */ +extern short var_48; +void +foo (double *r) +{ + if (var_48) + *r = 1234.5678; +} +