public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 1/5] Use alternative_mask for add_insn_allocno_copies
Date: Fri, 21 Jun 2019 13:40:00 -0000	[thread overview]
Message-ID: <mptk1dfm503.fsf@arm.com> (raw)
In-Reply-To: <mpto92rm51y.fsf@arm.com> (Richard Sandiford's message of "Fri,	21 Jun 2019 14:38:49 +0100")

add_insn_allocno_copies and its subroutines used HARD_REG_SET to
represent a bitmask of alternatives.  There's not really any connection
between the number of registers and the maximum number of alternatives,
so this patch uses alternative_mask instead (which wasn't around when
this code was added).

This is just a minor clean-up making way for later patches.


2019-06-21  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* ira-int.h (ira_setup_alts, ira_get_dup_out_num): Use
	alternative_mask instead of HARD_REG_SET to represent a
	bitmask of alternatives.
	* ira.c (ira_setup_alts, ira_get_dup_out_num): Likewise.
	* ira-conflicts.c (add_insn_allocno_copies): Likewise.

Index: gcc/ira-int.h
===================================================================
--- gcc/ira-int.h	2019-06-21 14:34:05.000000000 +0100
+++ gcc/ira-int.h	2019-06-21 14:34:05.883715050 +0100
@@ -963,8 +963,8 @@ extern void ira_print_disposition (FILE
 extern void ira_debug_disposition (void);
 extern void ira_debug_allocno_classes (void);
 extern void ira_init_register_move_cost (machine_mode);
-extern void ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts);
-extern int ira_get_dup_out_num (int op_num, HARD_REG_SET &alts);
+extern alternative_mask ira_setup_alts (rtx_insn *);
+extern int ira_get_dup_out_num (int, alternative_mask);
 
 /* ira-build.c */
 
Index: gcc/ira.c
===================================================================
--- gcc/ira.c	2019-06-21 14:34:05.000000000 +0100
+++ gcc/ira.c	2019-06-21 14:34:05.887715020 +0100
@@ -1784,9 +1784,12 @@ setup_prohibited_mode_move_regs (void)
 
 \f
 
-/* Setup possible alternatives in ALTS for INSN.  */
-void
-ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts)
+/* Extract INSN and return the set of alternatives that we should consider.
+   This excludes any alternatives whose constraints are obviously impossible
+   to meet (e.g. because the constraint requires a constant and the operand
+   is nonconstant).  */
+alternative_mask
+ira_setup_alts (rtx_insn *insn)
 {
   /* MAP nalt * nop -> start of constraints for given operand and
      alternative.  */
@@ -1798,7 +1801,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG
 
   extract_insn (insn);
   alternative_mask preferred = get_preferred_alternatives (insn);
-  CLEAR_HARD_REG_SET (alts);
+  alternative_mask alts = 0;
   insn_constraints.release ();
   insn_constraints.safe_grow_cleared (recog_data.n_operands
 				      * recog_data.n_alternatives + 1);
@@ -1833,8 +1836,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG
 	}
       for (nalt = 0; nalt < recog_data.n_alternatives; nalt++)
 	{
-	  if (!TEST_BIT (preferred, nalt)
-	      || TEST_HARD_REG_BIT (alts, nalt))
+	  if (!TEST_BIT (preferred, nalt) || TEST_BIT (alts, nalt))
 	    continue;
 
 	  for (nop = 0; nop < recog_data.n_operands; nop++)
@@ -1906,7 +1908,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG
 	      ;
 	    }
 	  if (nop >= recog_data.n_operands)
-	    SET_HARD_REG_BIT (alts, nalt);
+	    alts |= ALTERNATIVE_BIT (nalt);
 	}
       if (commutative < 0)
 	break;
@@ -1916,6 +1918,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG
       if (curr_swapped)
 	break;
     }
+  return alts;
 }
 
 /* Return the number of the output non-early clobber operand which
@@ -1923,7 +1926,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG
    negative value if there is no such operand).  The function takes
    only really possible alternatives into consideration.  */
 int
-ira_get_dup_out_num (int op_num, HARD_REG_SET &alts)
+ira_get_dup_out_num (int op_num, alternative_mask alts)
 {
   int curr_alt, c, original, dup;
   bool ignore_p, use_commut_op_p;
@@ -1940,7 +1943,7 @@ ira_get_dup_out_num (int op_num, HARD_RE
     {
       rtx op = recog_data.operand[op_num];
       
-      for (curr_alt = 0, ignore_p = !TEST_HARD_REG_BIT (alts, curr_alt),
+      for (curr_alt = 0, ignore_p = !TEST_BIT (alts, curr_alt),
 	   original = -1;;)
 	{
 	  c = *str;
@@ -1951,7 +1954,7 @@ ira_get_dup_out_num (int op_num, HARD_RE
 	  else if (c == ',')
 	    {
 	      curr_alt++;
-	      ignore_p = !TEST_HARD_REG_BIT (alts, curr_alt);
+	      ignore_p = !TEST_BIT (alts, curr_alt);
 	    }
 	  else if (! ignore_p)
 	    switch (c)
Index: gcc/ira-conflicts.c
===================================================================
--- gcc/ira-conflicts.c	2019-06-21 14:34:05.000000000 +0100
+++ gcc/ira-conflicts.c	2019-06-21 14:34:05.883715050 +0100
@@ -358,7 +358,7 @@ add_insn_allocno_copies (rtx_insn *insn)
   rtx set, operand, dup;
   bool bound_p[MAX_RECOG_OPERANDS];
   int i, n, freq;
-  HARD_REG_SET alts;
+  alternative_mask alts;
 
   freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn));
   if (freq == 0)
@@ -379,7 +379,7 @@ add_insn_allocno_copies (rtx_insn *insn)
      there are no dead registers, there will be no such copies.  */
   if (! find_reg_note (insn, REG_DEAD, NULL_RTX))
     return;
-  ira_setup_alts (insn, alts);
+  alts = ira_setup_alts (insn);
   for (i = 0; i < recog_data.n_operands; i++)
     bound_p[i] = false;
   for (i = 0; i < recog_data.n_operands; i++)

  reply	other threads:[~2019-06-21 13:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 13:38 [PATCH 0/5] Tweak IRA handling of tying and earlyclobbers Richard Sandiford
2019-06-21 13:40 ` Richard Sandiford [this message]
2019-06-28 11:46   ` [PATCH 1/5] Use alternative_mask for add_insn_allocno_copies Richard Sandiford
2019-06-28 14:17     ` Vladimir Makarov
2019-06-21 13:41 ` [PATCH 2/5] Simplify ira_setup_alts Richard Sandiford
2019-06-24 14:30   ` Vladimir Makarov
2019-06-21 13:42 ` [PATCH 3/5] Make ira_get_dup_out_num handle more cases Richard Sandiford
2019-06-24 14:32   ` Vladimir Makarov
2019-06-21 13:42 ` [PATCH 4/5] Allow earlyclobbers in ira_get_dup_out_num Richard Sandiford
2019-06-24 14:32   ` Vladimir Makarov
2019-06-21 13:43 ` [PATCH 5/5] Use ira_setup_alts for conflict detection Richard Sandiford
2019-06-24 14:33   ` Vladimir Makarov
2019-07-01  9:01     ` Richard Sandiford
2019-06-21 17:43 ` [PATCH 0/5] Tweak IRA handling of tying and earlyclobbers Richard Sandiford
2019-06-24  7:54   ` Eric Botcazou
2019-06-24  8:06     ` Richard Sandiford

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=mptk1dfm503.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).