From patchwork Sat Feb 11 15:59:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schulze Frielinghaus X-Patchwork-Id: 1740929 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=jYsyTCCS; 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 4PDb2N2Q3gz23qt for ; Sun, 12 Feb 2023 03:01:46 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5A5B3858409 for ; Sat, 11 Feb 2023 16:01:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5A5B3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676131301; bh=MVY1cBjjv3R19J0HlSKoI67xIV8dNZzY/pVhhTLlpBg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=jYsyTCCSmse/+OUtWRbmnjZRUTiqTlUV/fJeNll0Wag3AR0sucV2vo96vbvBuyTe6 W3Ngx05zgdMG0PipJCdIIbXlSggjwucPkvWz07KsqBGri1DuKr0BEP3fdwJAgwZZcj orof1vy8UgVbPDazTfo0fxB2wkWJNEsA+7xxKkKs= 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 A4D993858D32 for ; Sat, 11 Feb 2023 16:01:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4D993858D32 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31BFtKW4005832 for ; Sat, 11 Feb 2023 16:01:19 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3npe36r2qr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 11 Feb 2023 16:01:18 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31B2skYF010804 for ; Sat, 11 Feb 2023 16:01:17 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3np2n6rm63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 11 Feb 2023 16:01:17 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31BG1Dkw21889382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 11 Feb 2023 16:01:13 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B1092004B; Sat, 11 Feb 2023 16:01:13 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6550920040; Sat, 11 Feb 2023 16:01:13 +0000 (GMT) Received: from a8345010.lnxne.boe (unknown [9.152.108.100]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Sat, 11 Feb 2023 16:01:13 +0000 (GMT) To: krebbel@linux.ibm.com, rdapp@linux.ibm.com, gcc-patches@gcc.gnu.org Cc: Stefan Schulze Frielinghaus Subject: [PATCH] IBM zSystems: Do not propagate scheduler state across basic blocks [PR108102] Date: Sat, 11 Feb 2023 16:59:35 +0100 Message-Id: <20230211155934.3539787-1-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7wm9eilfSy5Od0QYNApJ2zCFHrLkD-X9 X-Proofpoint-GUID: 7wm9eilfSy5Od0QYNApJ2zCFHrLkD-X9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-11_09,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302110142 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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: Stefan Schulze Frielinghaus via Gcc-patches From: Stefan Schulze Frielinghaus Reply-To: Stefan Schulze Frielinghaus Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" So far we propagate scheduler state across basic blocks within EBBs and reset the state otherwise. In certain circumstances the entry block of an EBB might be empty, i.e., no_real_insns_p is true. In those cases scheduler state is not reset and subsequently wrong state is propagated to following blocks of the same EBB. Since the performance benefit of tracking state across basic blocks is questionable on modern hardware, simply reset the state for each basic block. Fix also resetting f{p,x}d_longrunning. Bootstrapped and regtested on IBM zSystems. Ok for mainline? gcc/ChangeLog: * config/s390/s390.cc (s390_bb_fallthru_entry_likely): Remove. (struct s390_sched_state): Initialise to zero. (s390_sched_variable_issue): For better debuggability also emit the current side. (s390_sched_init): Unconditionally reset scheduler state. --- gcc/config/s390/s390.cc | 42 +++++++---------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index a9bb610385b..9317f33e9c9 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -14872,29 +14872,6 @@ s390_z10_prevent_earlyload_conflicts (rtx_insn **ready, int *nready_p) ready[0] = tmp; } -/* Returns TRUE if BB is entered via a fallthru edge and all other - incoming edges are less than likely. */ -static bool -s390_bb_fallthru_entry_likely (basic_block bb) -{ - edge e, fallthru_edge; - edge_iterator ei; - - if (!bb) - return false; - - fallthru_edge = find_fallthru_edge (bb->preds); - if (!fallthru_edge) - return false; - - FOR_EACH_EDGE (e, ei, bb->preds) - if (e != fallthru_edge - && e->probability >= profile_probability::likely ()) - return false; - - return true; -} - struct s390_sched_state { /* Number of insns in the group. */ @@ -14905,7 +14882,7 @@ struct s390_sched_state bool group_of_two; } s390_sched_state; -static struct s390_sched_state sched_state = {0, 1, false}; +static struct s390_sched_state sched_state; #define S390_SCHED_ATTR_MASK_CRACKED 0x1 #define S390_SCHED_ATTR_MASK_EXPANDED 0x2 @@ -15405,7 +15382,7 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more) s390_get_unit_mask (insn, &units); - fprintf (file, ";;\t\tBACKEND: units on this side unused for: "); + fprintf (file, ";;\t\tBACKEND: units on this side (%d) unused for: ", sched_state.side); for (j = 0; j < units; j++) fprintf (file, "%d:%d ", j, last_scheduled_unit_distance[j][sched_state.side]); @@ -15443,17 +15420,12 @@ s390_sched_init (FILE *file ATTRIBUTE_UNUSED, current_sched_info->prev_head is the insn before the first insn of the block of insns to be scheduled. */ - rtx_insn *insn = current_sched_info->prev_head - ? NEXT_INSN (current_sched_info->prev_head) : NULL; - basic_block bb = insn ? BLOCK_FOR_INSN (insn) : NULL; - if (s390_tune < PROCESSOR_2964_Z13 || !s390_bb_fallthru_entry_likely (bb)) - { - last_scheduled_insn = NULL; - memset (last_scheduled_unit_distance, 0, + last_scheduled_insn = NULL; + memset (last_scheduled_unit_distance, 0, MAX_SCHED_UNITS * NUM_SIDES * sizeof (int)); - sched_state.group_state = 0; - sched_state.group_of_two = false; - } + memset (fpd_longrunning, 0, NUM_SIDES * sizeof (int)); + memset (fxd_longrunning, 0, NUM_SIDES * sizeof (int)); + sched_state = {}; } /* This target hook implementation for TARGET_LOOP_UNROLL_ADJUST calculates