public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
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 08:47:00 -0000	[thread overview]
Message-ID: <1456735599-21355-2-git-send-email-krebbel@linux.vnet.ibm.com> (raw)
In-Reply-To: <1456735599-21355-1-git-send-email-krebbel@linux.vnet.ibm.com>

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  <krebbel@linux.vnet.ibm.com>

	* 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);
 \f
 /* 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)
-- 
1.9.1

  parent reply	other threads:[~2016-02-29  8:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29  8:47 [PATCH 0/9] S/390 rework shift count handling - v3 Andreas Krebbel
2016-02-29  8:46 ` [PATCH 8/9] S/390: Use define_subst for the setmem patterns Andreas Krebbel
2016-02-29  8:46 ` [PATCH 3/9] S/390: Get rid of Y constraint in rotate patterns Andreas Krebbel
2016-02-29  8:46 ` [PATCH 9/9] S/390: Disallow SImode in s390_decompose_address Andreas Krebbel
2016-02-29  8:47 ` [PATCH 6/9] S/390: Get rid of Y constraint in tabort Andreas Krebbel
2016-02-29  8:47 ` [PATCH 2/9] S/390: Use enabled attribute overrides to disable alternatives Andreas Krebbel
2016-02-29  8:47 ` [PATCH 4/9] S/390: Get rid of Y constraint in left and logical right shift patterns Andreas Krebbel
2016-02-29  8:47 ` [PATCH 7/9] S/390: Get rid of Y constraint in vector.md Andreas Krebbel
2016-02-29 14:58   ` Ulrich Weigand
2016-03-01 15:11     ` Ulrich Weigand
2016-03-01 15:31       ` Andreas Krebbel
2016-03-08 12:51       ` [PATCH] S/390: Rename shift_count_or_setmem_operand to setmem_operand Andreas Krebbel
2016-02-29  8:47 ` [PATCH 5/9] S/390: Get rid of Y constraint in arithmetic right shift patterns Andreas Krebbel
2016-02-29  8:47 ` Andreas Krebbel [this message]
2016-02-29 13:37   ` [PATCH 1/9] gensupport: Fix define_subst operand renumbering Bernd Schmidt
2016-03-01  9:30     ` Andreas Krebbel
2016-03-01 12:15       ` James Greenhalgh
2016-03-01 12:17         ` Bernd Schmidt
2016-03-01 12:35         ` Andreas Krebbel
2016-03-01 13:38           ` James Greenhalgh
2016-03-01 14:55             ` Andreas Krebbel
2016-02-29 14:59 ` [PATCH 0/9] S/390 rework shift count handling - v3 Ulrich Weigand
2016-03-01  9:30   ` Andreas Krebbel
  -- strict thread matches above, loose matches on Subject: below --
2016-02-23 14:33 [PATCH 0/9] S/390 rework shift count handling - v2 Andreas Krebbel
2016-02-23 14:33 ` [PATCH 1/9] gensupport: Fix define_subst operand renumbering Andreas Krebbel
2016-01-14 16:34 [PATCH 0/9] S/390 rework shift count handling Andreas Krebbel
2016-01-14 16:44 ` [PATCH 1/9] gensupport: Fix define_subst operand renumbering Andreas Krebbel
2016-01-18 14:46   ` Bernd Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456735599-21355-2-git-send-email-krebbel@linux.vnet.ibm.com \
    --to=krebbel@linux.vnet.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).