From patchwork Tue Jun 13 12:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 1794485 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=IHsRR1rs; 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 4QgSQv5rlbz20Wq for ; Tue, 13 Jun 2023 22:24:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0052385840D for ; Tue, 13 Jun 2023 12:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0052385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686659045; bh=GCMkYQymjHv3gvjbs/4WZYwMtMpexV+vRNnhYq1pIuY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=IHsRR1rsWVVNnmtv9KlkW4WRfoWXXf5OpEHaI3E0lfcZGIfTNUPzCD2v44jMpmdMF bKbXmNocFYbN+OZYKN30CrvnywdeRIhkrS4uxiuDdu7EjmTM+1Z50he0mgbgCggrqK Avn5s9/6dWnh/dxbPaMJMHhS2Y4hvAhTypBH/J4M= 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 5418F3857C45; Tue, 13 Jun 2023 12:23:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5418F3857C45 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35DC2pdE019155; Tue, 13 Jun 2023 12:23:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r6qw08wsf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 12:23:44 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35DC88wF005846; Tue, 13 Jun 2023 12:23:43 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r6qw08wrk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 12:23:43 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35D6t0c9022350; Tue, 13 Jun 2023 12:23:41 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3r4gee245t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 12:23:41 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35DCNcEl44761510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Jun 2023 12:23:38 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 266BF20049; Tue, 13 Jun 2023 12:23:38 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C3A520043; Tue, 13 Jun 2023 12:23:36 +0000 (GMT) Received: from ltcden2-lp1.aus.stglabs.ibm.com (unknown [9.3.90.43]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Jun 2023 12:23:36 +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, jeffreyalaw@gmail.com Subject: [PATCH] rs6000: replace '(const_int 0)' to 'unspec:BLK [(const_int 0)]' for stack_tie Date: Tue, 13 Jun 2023 20:23:35 +0800 Message-Id: <20230613122335.2108620-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.39.3 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6m_8c9VUQEEffX2AvM1oRyx1bjhvIRBs X-Proofpoint-GUID: gFVV1-gJYwsgM76_zJ-KneaJi00rv8e3 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-13_04,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 mlxscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306130107 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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. Compare with previous version, this addes ChangeLog and removes const_anchor parts. https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621356.html. Bootstrap®test pass on ppc64{,le}. Is this ok for trunk? BR, Jeff (Jiufu Guo) gcc/ChangeLog: * config/rs6000/predicates.md (tie_operand): Update to match new stack_tie pattern. * config/rs6000/rs6000-logue.cc (rs6000_emit_stack_tie): Update to use the new stack_tie pattern. * config/rs6000/rs6000.md (UNSPEC_TIE): New UNSPEC. (restore_stack_block): Update to use the new stack_tie pattern. (restore_stack_nonlocal): Likewise. (stack_tie): Update pattern to use UNSPEC_TIE. (stack_restore_tie): Likewise. --- gcc/config/rs6000/predicates.md | 11 +++++++---- gcc/config/rs6000/rs6000-logue.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.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