From patchwork Wed Aug 17 11:50:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schulze Frielinghaus X-Patchwork-Id: 574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp2596749pxh; Wed, 17 Aug 2022 04:57:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR6aDi93VUOizWOk5bBDlk9kHRBvT+xAuYRjk56NnKklLx1Q4ANVLqEB8SnKp1LttdyyWW8O X-Received: by 2002:a17:907:7292:b0:733:1965:3176 with SMTP id dt18-20020a170907729200b0073319653176mr16012796ejc.318.1660737433845; Wed, 17 Aug 2022 04:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660737433; cv=none; d=google.com; s=arc-20160816; b=ps92lgYgVNxBx2dvNRNfyQAodlZtAT+zlsgi4HuN9YVqhkQKEhGxwDnY6iIM/HzhIO U/UFFV5OSkcSQW/Zn98zpY/dJy9oDQQqtbUjv7NoFDhekc3tO/iI4p0H8XSHyTHu8+XB OyCZ8kugHiiMrgXFflANjTYkoFXWnFg04EN/m/yLaiKZiZUM0FTDfnmoISCXqJaozxzI 1bn8fBV+aw3uSo7Uf32nSaHQbY8Mc8y8qwdcXAhmJcJWNp+ZHamGQkv5GTTba8urzo8y MDo+B7h52l4xha0VVje0qpnMPSoMAZWFaTetkHEjuCUwn0lb8bhV8CyGsN3hD9/iMpW1 LFRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=lvYbD2g86llzEBy8dKqaYbYjPnsFKsoT5dLrURTCZaE=; b=e1FYDArqn0TrjR/sZU8apH7Uymxfb2oYVANdYIrKHbhdI14pXFLOhN2egzP0+hbQ2q THVdgBrXGTc+/Y80Hhzi2n8cXjEPhokQkBzn+MuP9ZIL6wzM9GfwxsQT4sDZN/qFvZ3V /bjLXQe1D+5ypGs3cv8XQEo5GPUb4yJUN1QRdBNSIYtx1o2f37DOxqgAdktdpQvRGBdb etV42YYzZR/x+DNvvbJpVxFsI6v6DTMvvFlbBri3MhTRoe5mgN6Cn0BQHrFUMo/bZMqM QunVZxMtgWA0dc9w6MRjBFkgmrcbaBQ9sV5fQufZra3bccvnjF0N614hc/Uo989Q5g2R thlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=THzyfDrv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ds1-20020a170907724100b00731148bc546si13941005ejc.38.2022.08.17.04.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 04:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=THzyfDrv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 836C63858C50 for ; Wed, 17 Aug 2022 11:57:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 836C63858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660737432; bh=lvYbD2g86llzEBy8dKqaYbYjPnsFKsoT5dLrURTCZaE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=THzyfDrvYZIT4Pj+G5rRY78k7zx5oBO34bsYifj4JUX+3kxknOmsZ2yW5uKJkreQT ONnLBbnVGI4h4EB7gMgtxroLOTTxYZ5K6gkw31YTW+X0RuUihPA2vieFHX4V1gvVox wUxSFBbNSqIc0Q6DUTqoA4dCZ1k8COjXsrvsOhfY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E68CA3858D1E for ; Wed, 17 Aug 2022 11:56:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E68CA3858D1E Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27HBtU5X002436 for ; Wed, 17 Aug 2022 11:56:28 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j0yvu00a1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Aug 2022 11:56:27 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27HBomP7021970 for ; Wed, 17 Aug 2022 11:56:25 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3hx3k8vdgg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Aug 2022 11:56:25 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27HBuLbO30081466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Aug 2022 11:56:22 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C986742049; Wed, 17 Aug 2022 11:56:21 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A041942045; Wed, 17 Aug 2022 11:56:21 +0000 (GMT) Received: from t8345026.lnxne.boe (unknown [9.152.108.100]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 17 Aug 2022 11:56:21 +0000 (GMT) To: krebbel@linux.ibm.com, gcc-patches@gcc.gnu.org Subject: [PATCH] IBM zSystems: Fix function_ok_for_sibcall [PR106355] Date: Wed, 17 Aug 2022 13:50:45 +0200 Message-Id: <20220817115044.1853371-1-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4bevszhglPFzEbheOogOv35ReQ1L1fFu X-Proofpoint-GUID: 4bevszhglPFzEbheOogOv35ReQ1L1fFu 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-08-17_05,2022-08-16_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208170045 X-Spam-Status: No, score=-8.4 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, 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: Stefan Schulze Frielinghaus via Gcc-patches From: Stefan Schulze Frielinghaus Reply-To: Stefan Schulze Frielinghaus 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-THRID: =?utf-8?q?1741409415515558106?= X-GMAIL-MSGID: =?utf-8?q?1741409415515558106?= For a parameter with BLKmode we cannot use REG_NREGS in order to determine the number of consecutive registers. Streamlined this with the implementation of s390_function_arg. Fix some indentation whitespace, too. Assuming bootstrap and regtest are ok for mainline and gcc-{10,11,12}, ok to install for all of those? PR target/106355 gcc/ChangeLog: * config/s390/s390.cc (s390_call_saved_register_used): For a parameter with BLKmode fix determining number of consecutive registers. gcc/testsuite/ChangeLog: * gcc.target/s390/pr106355.h: Common code for new tests. * gcc.target/s390/pr106355-1.c: New test. * gcc.target/s390/pr106355-2.c: New test. * gcc.target/s390/pr106355-3.c: New test. --- gcc/config/s390/s390.cc | 47 +++++++++++----------- gcc/testsuite/gcc.target/s390/pr106355-1.c | 42 +++++++++++++++++++ gcc/testsuite/gcc.target/s390/pr106355-2.c | 8 ++++ gcc/testsuite/gcc.target/s390/pr106355-3.c | 8 ++++ gcc/testsuite/gcc.target/s390/pr106355.h | 18 +++++++++ 5 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/pr106355-1.c create mode 100644 gcc/testsuite/gcc.target/s390/pr106355-2.c create mode 100644 gcc/testsuite/gcc.target/s390/pr106355-3.c create mode 100644 gcc/testsuite/gcc.target/s390/pr106355.h diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 5aaf76a9490..85e5b2cb2a2 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -13712,36 +13712,37 @@ s390_call_saved_register_used (tree call_expr) function_arg_info arg (TREE_TYPE (parameter), /*named=*/true); apply_pass_by_reference_rules (&cum_v, arg); - parm_rtx = s390_function_arg (cum, arg); + parm_rtx = s390_function_arg (cum, arg); - s390_function_arg_advance (cum, arg); + s390_function_arg_advance (cum, arg); - if (!parm_rtx) - continue; - - if (REG_P (parm_rtx)) - { - for (reg = 0; reg < REG_NREGS (parm_rtx); reg++) - if (!call_used_or_fixed_reg_p (reg + REGNO (parm_rtx))) - return true; - } + if (!parm_rtx) + continue; - if (GET_CODE (parm_rtx) == PARALLEL) - { - int i; + if (REG_P (parm_rtx)) + { + int size = s390_function_arg_size (arg.mode, arg.type); + int nregs = (size + UNITS_PER_LONG - 1) / UNITS_PER_LONG; - for (i = 0; i < XVECLEN (parm_rtx, 0); i++) - { - rtx r = XEXP (XVECEXP (parm_rtx, 0, i), 0); + for (reg = 0; reg < nregs; reg++) + if (!call_used_or_fixed_reg_p (reg + REGNO (parm_rtx))) + return true; + } + else if (GET_CODE (parm_rtx) == PARALLEL) + { + int i; - gcc_assert (REG_P (r)); + for (i = 0; i < XVECLEN (parm_rtx, 0); i++) + { + rtx r = XEXP (XVECEXP (parm_rtx, 0, i), 0); - for (reg = 0; reg < REG_NREGS (r); reg++) - if (!call_used_or_fixed_reg_p (reg + REGNO (r))) - return true; - } - } + gcc_assert (REG_P (r)); + gcc_assert (REG_NREGS (r) == 1); + if (!call_used_or_fixed_reg_p (REGNO (r))) + return true; + } + } } return false; } diff --git a/gcc/testsuite/gcc.target/s390/pr106355-1.c b/gcc/testsuite/gcc.target/s390/pr106355-1.c new file mode 100644 index 00000000000..1ec0f6b25ac --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr106355-1.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-foptimize-sibling-calls" } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,bar4} } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,bar8} } } */ + +/* Parameter E is passed in GPR 6 which is call-saved which prohibits + sibling call optimization. This must hold true also if the mode of the + parameter is BLKmode. */ + +/* 4 byte */ + +typedef struct +{ + char x; + char y[3]; +} t4; + +extern t4 e4; + +extern void bar4 (int a, int b, int c, int d, t4 e4); + +void foo4 (int a, int b, int c, int d) +{ + bar4 (a, b, c, d, e4); +} + +/* 8 byte */ + +typedef struct +{ + short x; + char y[6]; +} t8; + +extern t8 e8; + +extern void bar8 (int a, int b, int c, int d, t8 e8); + +void foo8 (int a, int b, int c, int d) +{ + bar8 (a, b, c, d, e8); +} diff --git a/gcc/testsuite/gcc.target/s390/pr106355-2.c b/gcc/testsuite/gcc.target/s390/pr106355-2.c new file mode 100644 index 00000000000..ddbdba5d278 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr106355-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { s390-*-* } } } */ +/* { dg-options "-foptimize-sibling-calls -mzarch" } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,bar} } } */ + +/* This tests function s390_call_saved_register_used where + GET_CODE (parm_rtx) == PARALLEL holds. */ + +#include "pr106355.h" diff --git a/gcc/testsuite/gcc.target/s390/pr106355-3.c b/gcc/testsuite/gcc.target/s390/pr106355-3.c new file mode 100644 index 00000000000..39daea44fc4 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr106355-3.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { s390-*-* } } } */ +/* { dg-options "-foptimize-sibling-calls -mesa" } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,bar} } } */ + +/* This tests function s390_call_saved_register_used where + REG_P (parm_rtx) and nregs == 2 holds. */ + +#include "pr106355.h" diff --git a/gcc/testsuite/gcc.target/s390/pr106355.h b/gcc/testsuite/gcc.target/s390/pr106355.h new file mode 100644 index 00000000000..362908e5913 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr106355.h @@ -0,0 +1,18 @@ +/* For the S/390 ABI parameter D is passed in GPR 5 and 6 and the latter is + call-saved which prohibits sibling call optimization. This must hold true + also if the mode of the parameter is BLKmode. */ + +typedef struct +{ + short x; + char y[6]; +} t; + +extern t d; + +extern void bar (int a, int b, int c, t d); + +void foo (int a, int b, int c) +{ + bar (a, b, c, d); +}