From patchwork Wed Sep 5 11:51:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 966340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485176-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LXvsLKZU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4252Bx31Z4z9s5c for ; Wed, 5 Sep 2018 21:52:57 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type; q=dns; s=default; b=degFTVbsKXJ0QUgthLMzUdwmcipV+ U9Tbek+ip/RlcW0z9i0i3XcJv7ytk8TW9XmjknssIkNJUPwcf6NqMElKaglS0WGA 4u1y4n12ZiM3tDB/XVcvr9LkcrLXuV2Z3NpPP0DEdgLsd5CGBQHb/g/3w7LdgqTF PW7T8whvm75aB0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type; s=default; bh=ubhGFTGjygepyCpzZM8o/9GMHJg=; b=LXv sLKZUZJB1vAEZ0RTQLY3XDnc2rgRsCjd1IshXzULLI1Zl9ZVMc+R8IbJsJyaTsIy CY8NQtu0VLuwsdT+bu/YW8eECY0AMg4KG4Y0YN1YgE0bHrKWC+hvIxMZcmmZJvlf z4P/ByBQQALXszZayhIt1aiYcSsLvHa5i5IlRGN8= Received: (qmail 95440 invoked by alias); 5 Sep 2018 11:51:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 95355 invoked by uid 89); 5 Sep 2018 11:51:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=alt, incidentally, freedom X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Sep 2018 11:51:37 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxWLP-00064N-0l for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 07:51:36 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:45544) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fxWLO-00062r-Nu for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 07:51:34 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fxWLN-0005ql-QS from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 04:51:33 -0700 Received: from build6-trusty-cs.sje.mentorg.com (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 5 Sep 2018 12:51:29 +0100 From: To: Subject: [PATCH 15/25] Don't double-count early-clobber matches. Date: Wed, 5 Sep 2018 12:51:16 +0100 Message-ID: <99dbde9ad7afdc6199cfc2f024d8a039028fc208.1536144068.git.ams@codesourcery.com> In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Given a pattern with a number of operands: (match_operand 0 "" "=&v") (match_operand 1 "" " v0") (match_operand 2 "" " v0") (match_operand 3 "" " v0") GCC will currently increment "reject" once, for operand 0, and then decrement it once for each of the other operands, ending with reject == -2 and an assertion failure. If there's a conflict then it might try to decrement reject yet again. Incidentally, what these patterns are trying to achieve is an allocation in which operand 0 may match one of the other operands, but may not partially overlap any of them. Ideally there'd be a better way to do this. In any case, it will affect any pattern in which multiple operands may (or must) match an early-clobber operand. The patch only allows a reject-- when one has not already occurred, for that operand. 2018-09-05 Andrew Stubbs gcc/ * lra-constraints.c (process_alt_operands): Check matching_early_clobber before decrementing reject, and set matching_early_clobber after. * lra-int.h (struct lra_operand_data): Add matching_early_clobber. * lra.c (setup_operand_alternative): Initialize matching_early_clobber. --- gcc/lra-constraints.c | 22 ++++++++++++++-------- gcc/lra-int.h | 3 +++ gcc/lra.c | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 8be4d46..55163f1 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -2202,7 +2202,13 @@ process_alt_operands (int only_alternative) " %d Matching earlyclobber alt:" " reject--\n", nop); - reject--; + if (!curr_static_id->operand[m] + .matching_early_clobber) + { + reject--; + curr_static_id->operand[m] + .matching_early_clobber = 1; + } } /* Otherwise we prefer no matching alternatives because it gives more freedom @@ -2948,15 +2954,11 @@ process_alt_operands (int only_alternative) curr_alt_dont_inherit_ops[curr_alt_dont_inherit_ops_num++] = last_conflict_j; losers++; - /* Early clobber was already reflected in REJECT. */ - lra_assert (reject > 0); if (lra_dump_file != NULL) fprintf (lra_dump_file, " %d Conflict early clobber reload: reject--\n", i); - reject--; - overall += LRA_LOSER_COST_FACTOR - 1; } else { @@ -2980,17 +2982,21 @@ process_alt_operands (int only_alternative) } curr_alt_win[i] = curr_alt_match_win[i] = false; losers++; - /* Early clobber was already reflected in REJECT. */ - lra_assert (reject > 0); if (lra_dump_file != NULL) fprintf (lra_dump_file, " %d Matched conflict early clobber reloads: " "reject--\n", i); + } + /* Early clobber was already reflected in REJECT. */ + if (!curr_static_id->operand[i].matching_early_clobber) + { + lra_assert (reject > 0); reject--; - overall += LRA_LOSER_COST_FACTOR - 1; + curr_static_id->operand[i].matching_early_clobber = 1; } + overall += LRA_LOSER_COST_FACTOR - 1; } if (lra_dump_file != NULL) fprintf (lra_dump_file, " alt=%d,overall=%d,losers=%d,rld_nregs=%d\n", diff --git a/gcc/lra-int.h b/gcc/lra-int.h index 5267b53..f193e1f 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -147,6 +147,9 @@ struct lra_operand_data This field is set up every time when corresponding operand_alternative in lra_static_insn_data is set up. */ unsigned int early_clobber : 1; + /* True if there is an early clobber that has a matching alternative. + This field is used to prevent multiple matches being counted. */ + unsigned int matching_early_clobber : 1; /* True if the operand is an address. */ unsigned int is_address : 1; }; diff --git a/gcc/lra.c b/gcc/lra.c index aa768fb..01dd8b8 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -797,6 +797,7 @@ setup_operand_alternative (lra_insn_recog_data_t data, { static_data->operand[i].early_clobber_alts = 0; static_data->operand[i].early_clobber = false; + static_data->operand[i].matching_early_clobber = false; static_data->operand[i].is_address = false; if (static_data->operand[i].constraint[0] == '%') {