From patchwork Mon Jun 12 13:19:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 1793933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Sbi0bY4d; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qfsjm721Sz20QH for ; Mon, 12 Jun 2023 23:19:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 26BDC3858425 for ; Mon, 12 Jun 2023 13:19:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26BDC3858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686575993; bh=mfv9d988vPQHT1R/qA5QF5F0WMk8USxMNBR50++QYys=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Sbi0bY4da9PimcXZBjXJD4zGMpxcvj8+TN80r5zuZ5gUqWn53av53ojcNFurUv2C7 3SwQoAPzH9Qz3+gSOekrUBsIGWdU8oz+bKQ+P7Etm+RzMqZlyxG9YQfgVTLxY0QN/H 8cAnHkh5JWDyhdUO3oQnf+DMgfIMQNmXahrGoLkU= 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 4AF953858C33; Mon, 12 Jun 2023 13:19:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AF953858C33 Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CDGTFs032278; Mon, 12 Jun 2023 13:19:28 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r643u01s2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jun 2023 13:19:27 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35CDGvMT000423; Mon, 12 Jun 2023 13:19:27 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r643u01rd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jun 2023 13:19:27 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35C4pEYP007408; Mon, 12 Jun 2023 13:19:25 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3r4gt4s3ey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jun 2023 13:19:25 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35CDJLCH21693140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 13:19:21 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB39A20043; Mon, 12 Jun 2023 13:19:21 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 715AF2004B; Mon, 12 Jun 2023 13:19:20 +0000 (GMT) Received: from ltcden2-lp1.aus.stglabs.ibm.com (unknown [9.3.90.43]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 12 Jun 2023 13:19:20 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, guojiufu@linux.ibm.com, rguenther@suse.de, richard.sandiford@arm.com Subject: [PATCH] rs6000: replace '(const_int 0)' to 'unspec:BLK [(const_int 0)]' for stack_tie Date: Mon, 12 Jun 2023 21:19:19 +0800 Message-Id: <20230612131919.269681-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _mZA03lKNHzU6b77j5UgSxfJcTjmLPrf X-Proofpoint-GUID: sHAQm1XWXH-eDBtXiTwlzvwBvoENLhpj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_06,2023-06-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 clxscore=1015 mlxscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120113 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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 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: Jiufu Guo Reply-To: Jiufu Guo Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, For stack_tie, currently below insn is generated: (insn 15 14 16 3 (parallel [ (set (mem/c:BLK (reg/f:DI 1 1) [1 A8]) (const_int 0 [0])) ]) "/home/guojiufu/temp/gdb.c":13:3 922 {stack_tie} (nil)) It is "set (mem/c:BLK (reg/f:DI 1 1) (const_int 0 [0])". This maybe looks like "a memory block is zerored", while actually stack_tie may be more like a placeholder, and does not generate any thing. To avoid potential misunderstand, "UNPSEC:BLK [(const_int 0)].." could be used here like other ports. This patch does this. Bootstrap®test pass on ppc64{,le}. Is this ok for trunk? BR, Jeff (Jiufu Guo) --- gcc/config/rs6000/predicates.md | 11 +++++++---- gcc/config/rs6000/rs6000-logue.cc | 4 +++- gcc/config/rs6000/rs6000.cc | 4 ++++ gcc/config/rs6000/rs6000.md | 14 ++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index a16ee30f0c0..4748cb37ce8 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -1854,10 +1854,13 @@ (define_predicate "stmw_operation" (define_predicate "tie_operand" (match_code "parallel") { - return (GET_CODE (XVECEXP (op, 0, 0)) == SET - && MEM_P (XEXP (XVECEXP (op, 0, 0), 0)) - && GET_MODE (XEXP (XVECEXP (op, 0, 0), 0)) == BLKmode - && XEXP (XVECEXP (op, 0, 0), 1) == const0_rtx); + rtx set = XVECEXP (op, 0, 0); + return (GET_CODE (set) == SET + && MEM_P (SET_DEST (set)) + && GET_MODE (SET_DEST (set)) == BLKmode + && GET_CODE (SET_SRC (set)) == UNSPEC + && XINT (SET_SRC (set), 1) == UNSPEC_TIE + && XVECEXP (SET_SRC (set), 0, 0) == const0_rtx); }) ;; Match a small code model toc reference (or medium and large diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index bc6b153b59f..b99f43a8282 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -1463,7 +1463,9 @@ rs6000_emit_stack_tie (rtx fp, bool hard_frame_needed) while (--i >= 0) { rtx mem = gen_frame_mem (BLKmode, regs[i]); - RTVEC_ELT (p, i) = gen_rtx_SET (mem, const0_rtx); + RTVEC_ELT (p, i) + = gen_rtx_SET (mem, gen_rtx_UNSPEC (BLKmode, gen_rtvec (1, const0_rtx), + UNSPEC_TIE)); } emit_insn (gen_stack_tie (gen_rtx_PARALLEL (VOIDmode, p))); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index d197c3f3289..0c81ebea711 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1760,6 +1760,10 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_UPDATE_IPA_FN_TARGET_INFO #define TARGET_UPDATE_IPA_FN_TARGET_INFO rs6000_update_ipa_fn_target_info + +#undef TARGET_CONST_ANCHOR +#define TARGET_CONST_ANCHOR 0x8000 + /* Processor table. */ diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index b0db8ae508d..fdcf8347812 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -158,6 +158,7 @@ (define_c_enum "unspec" UNSPEC_HASHCHK UNSPEC_XXSPLTIDP_CONST UNSPEC_XXSPLTIW_CONST + UNSPEC_TIE ]) ;; @@ -10828,7 +10829,9 @@ (define_expand "restore_stack_block" operands[4] = gen_frame_mem (Pmode, operands[1]); p = rtvec_alloc (1); RTVEC_ELT (p, 0) = gen_rtx_SET (gen_frame_mem (BLKmode, operands[0]), - const0_rtx); + gen_rtx_UNSPEC (BLKmode, + gen_rtvec (1, const0_rtx), + UNSPEC_TIE)); operands[5] = gen_rtx_PARALLEL (VOIDmode, p); }) @@ -10866,7 +10869,9 @@ (define_expand "restore_stack_nonlocal" operands[5] = gen_frame_mem (Pmode, operands[3]); p = rtvec_alloc (1); RTVEC_ELT (p, 0) = gen_rtx_SET (gen_frame_mem (BLKmode, operands[0]), - const0_rtx); + gen_rtx_UNSPEC (BLKmode, + gen_rtvec (1, const0_rtx), + UNSPEC_TIE)); operands[6] = gen_rtx_PARALLEL (VOIDmode, p); }) @@ -13898,7 +13903,8 @@ (define_insn "*save_fpregs__r1" ; not be moved over loads from or stores to stack memory. (define_insn "stack_tie" [(match_parallel 0 "tie_operand" - [(set (mem:BLK (reg 1)) (const_int 0))])] + [(set (mem:BLK (reg 1)) + (unspec:BLK [(const_int 0)] UNSPEC_TIE))])] "" "" [(set_attr "length" "0")]) @@ -13910,7 +13916,7 @@ (define_insn "stack_restore_tie" [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") (match_operand:SI 2 "reg_or_cint_operand" "O,rI"))) - (set (mem:BLK (scratch)) (const_int 0))] + (set (mem:BLK (scratch)) (unspec:BLK [(const_int 0)] UNSPEC_TIE))] "TARGET_32BIT" "@ mr %0,%1