From patchwork Mon Feb 29 08:46:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 589773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ECD61140324 for ; Mon, 29 Feb 2016 19:47:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=dlIcZRc7; dkim-atps=neutral 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:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=FE8shIlwWP8R+iB9981dG5a6x9yWFIsoFbo9UEunT4i/PcLAAtIsz cHeBwIKyRgk8Z62pGrFPcjm4NaBzE/9S9m+GiLSBJD78rIzBqg/kfrdBT3H/VgRB n1X/MqcND+Yd+eRj3++FP4F75IeWJf9S9fNEZkxh6ciGjKz6NDb/ig= 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:cc:subject:date:message-id:in-reply-to:references; s= default; bh=a4/aCtORvV+aknBA2wyNqSRD9NQ=; b=dlIcZRc7jh4sOcZ0dcOC 7h0aMP8jD2gxu2DboZa6lTIlMLL8Zd/9VRJmlUdMZBCdrVoSW9SzTYxnLTxJeXh9 ZEOKSRbN/o1qR7sQkDxIx7GqWllsepNUZObVUjxGB5DZLWszx0tLi8AaUqSmwBfs vct5sBJtOV1w3Dr6GRvMLu8= Received: (qmail 75620 invoked by alias); 29 Feb 2016 08:46:50 -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 75447 invoked by uid 89); 29 Feb 2016 08:46:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=1267, visits, occupied, sk:constra X-HELO: e06smtp13.uk.ibm.com Received: from e06smtp13.uk.ibm.com (HELO e06smtp13.uk.ibm.com) (195.75.94.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 29 Feb 2016 08:46:47 +0000 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 Feb 2016 08:46:44 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 Feb 2016 08:46:41 -0000 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: krebbel@linux.vnet.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id DBFDE2190056 for ; Mon, 29 Feb 2016 08:46:24 +0000 (GMT) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1T8kfc08585652 for ; Mon, 29 Feb 2016 08:46:41 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1T8keu6001743 for ; Mon, 29 Feb 2016 03:46:40 -0500 Received: from maggie.boeblingen.de.ibm.com (dyn-9-152-212-123.boeblingen.de.ibm.com [9.152.212.123]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u1T8kd3s001677 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO); Mon, 29 Feb 2016 03:46:40 -0500 From: Andreas Krebbel To: gcc-patches@gcc.gnu.org Cc: uweigand@de.ibm.com Subject: [PATCH 1/9] gensupport: Fix define_subst operand renumbering. Date: Mon, 29 Feb 2016 09:46:31 +0100 Message-Id: <1456735599-21355-2-git-send-email-krebbel@linux.vnet.ibm.com> In-Reply-To: <1456735599-21355-1-git-send-email-krebbel@linux.vnet.ibm.com> References: <1456735599-21355-1-git-send-email-krebbel@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16022908-0013-0000-0000-000008CE45BF X-IsSubscribed: yes When processing substitutions the operands are renumbered. To find a free operand number the array used_operands_numbers is used. Currently this array is used to assign new numbers before all the RTXes in the vector have been processed. I did run into problems with this for insns where a match_dup occurred in a later (use ...) operand referring to an earlier operand (e.g. s390.md "setmem_long"). The patch splits the loop doing the processing into two in order to have all the operand numbers collected already when assigning new numbers. Bootstrapped and regtested on s390, s390x, and x86_64. Ok for mainline? Bye, -Andreas- gcc/ChangeLog: 2016-02-29 Andreas Krebbel * gensupport.c (process_substs_on_one_elem): Split loop to complete mark_operands_used_in_match_dup on all expressions in the vector first. (adjust_operands_numbers): Inline into process_substs_on_one_elem and remove function. --- gcc/gensupport.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 8c5a1ab..de29579 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -126,7 +126,10 @@ static const char * duplicate_each_alternative (const char * str, int n_dup); typedef const char * (*constraints_handler_t) (const char *, int); static rtx alter_constraints (rtx, int, constraints_handler_t); -static rtx adjust_operands_numbers (rtx); + +static void mark_operands_used_in_match_dup (rtx); +static void renumerate_operands_in_pattern (rtx); + static rtx replace_duplicating_operands_in_pattern (rtx); /* Make a version of gen_rtx_CONST_INT so that GEN_INT can be used in @@ -1844,7 +1847,18 @@ process_substs_on_one_elem (struct queue_elem *elem, subst_pattern = alter_constraints (subst_pattern, alternatives, duplicate_each_alternative); - subst_pattern = adjust_operands_numbers (subst_pattern); + mark_operands_used_in_match_dup (subst_pattern); + RTVEC_ELT (subst_pattern_vec, j) = subst_pattern; + } + + for (j = 0; j < XVECLEN (subst_elem->data, 3); j++) + { + subst_pattern = RTVEC_ELT (subst_pattern_vec, j); + + /* The number of MATCH_OPERANDs in the output pattern might + change. This routine assigns new numbers to the + MATCH_OPERAND expressions to avoid collisions. */ + renumerate_operands_in_pattern (subst_pattern); /* Substitute match_dup and match_op_dup in the new pattern and duplicate constraints. */ @@ -1857,7 +1871,6 @@ process_substs_on_one_elem (struct queue_elem *elem, if (GET_CODE (elem->data) == DEFINE_EXPAND) remove_constraints (subst_pattern); - RTVEC_ELT (subst_pattern_vec, j) = subst_pattern; } XVEC (elem->data, 1) = subst_pattern_vec; @@ -1927,7 +1940,7 @@ mark_operands_from_match_dup (rtx pattern) } } -/* This is a subroutine of adjust_operands_numbers. +/* This is a subroutine of process_substs_on_one_elem. It goes through all expressions in PATTERN and when MATCH_DUP is met, all MATCH_OPERANDs inside it is marked as occupied. The process of marking is done by routin mark_operands_from_match_dup. */ @@ -1973,10 +1986,9 @@ find_first_unused_number_of_operand () return MAX_OPERANDS; } -/* This is subroutine of adjust_operands_numbers. - It visits all expressions in PATTERN and assigns not-occupied - operand indexes to MATCH_OPERANDs and MATCH_OPERATORs of this - PATTERN. */ +/* This is a subroutine of process_substs_on_one_elem. It visits all + expressions in PATTERN and assigns not-occupied operand indexes to + MATCH_OPERANDs and MATCH_OPERATORs of this PATTERN. */ static void renumerate_operands_in_pattern (rtx pattern) { @@ -2011,23 +2023,6 @@ renumerate_operands_in_pattern (rtx pattern) } } -/* If output pattern of define_subst contains MATCH_DUP, then this - expression would be replaced with the pattern, matched with - MATCH_OPERAND from input pattern. This pattern could contain any - number of MATCH_OPERANDs, MATCH_OPERATORs etc., so it's possible - that a MATCH_OPERAND from output_pattern (if any) would have the - same number, as MATCH_OPERAND from copied pattern. To avoid such - indexes overlapping, we assign new indexes to MATCH_OPERANDs, - laying in the output pattern outside of MATCH_DUPs. */ -static rtx -adjust_operands_numbers (rtx pattern) -{ - mark_operands_used_in_match_dup (pattern); - - renumerate_operands_in_pattern (pattern); - - return pattern; -} /* Generate RTL expression (match_dup OPNO)