public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hp@bitrange.com>
To: Vladimir Makarov <vmakarov@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: FORBIDDEN_INC_DEC_CLASSES in ira-costs.c
Date: Fri, 10 Jun 2011 03:46:00 -0000	[thread overview]
Message-ID: <alpine.BSF.2.00.1106092254551.61896@dair.pair.com> (raw)
In-Reply-To: <4DF0EF39.5020409@redhat.com>

On Thu, 9 Jun 2011, Vladimir Makarov wrote:
> On 06/08/2011 12:37 PM, Hans-Peter Nilsson wrote:
> > There's a lot of dead code inside the obsolete (removed in 2009)
> > and nowhere else set #ifdef FORBIDDEN_INC_DEC_CLASSES.
> > Remove and poison?
> >
> Yes, I believe so.
> > I'd say borderline obvious, but maybe there's instead reason to
> > reinstate it, if that code is tested and supposed to be live.
> I can not remember a reason to save it.  A big part of ira-costs.c was
> inherited from old reglcasses.c before the macro was removed.  Probably
> therefore it occurred again.
>
> Thanks for finding this.  I'd really appreciate if you submit a patch removing
> this.  I'll try to give it a quick review.

Tested by adding a #define FORBIDDEN_INC_DEC_CLASSES xyzzy to cris.h
and observing (1) without poison, build dies because of references to
undefined forbidden_inc_dec_class (ira-costs.c being the sole "referer")
and (2) with poison, compilation dies at first compilation including
cris.h due to the poisoning, (3) without the #define-dummy but with
poison, compilation dies in ira-costs.c on first reference to
FORBIDDEN_INC_DEC_CLASSES due to the poisoning, so you don't have to
trust me on my word that I managed to remove them all. :)
Thus, except for the comment adjustments and formatting, the removal is
mechanical and self-checking. ...and no warnings this time!

Ok?

	* ira-costs.c: Remove #ifdefs on dead FORBIDDEN_INC_DEC_CLASSES.
	Adjust comments.
	* system.h (FORBIDDEN_INC_DEC_CLASSES): Poison.

Index: system.h
===================================================================
--- system.h	(revision 174865)
+++ system.h	(working copy)
@@ -826,7 +826,8 @@ extern void fancy_abort (const char *, i
 	FUNCTION_ARG_BOUNDARY MUST_USE_SJLJ_EXCEPTIONS US_SOFTWARE_GOFAST  \
 	USING_SVR4_H SVR4_ASM_SPEC FUNCTION_ARG FUNCTION_ARG_ADVANCE	   \
 	FUNCTION_INCOMING_ARG IRA_COVER_CLASSES TARGET_VERSION		   \
-	MACHINE_TYPE TARGET_HAS_TARGETCM ASM_OUTPUT_BSS
+	MACHINE_TYPE TARGET_HAS_TARGETCM ASM_OUTPUT_BSS			   \
+	FORBIDDEN_INC_DEC_CLASSES

 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\
Index: ira-costs.c
===================================================================
--- ira-costs.c	(revision 174878)
+++ ira-costs.c	(working copy)
@@ -46,15 +46,9 @@ static bool pseudo_classes_defined_p = f
 /* TRUE if we work with allocnos.  Otherwise we work with pseudos.  */
 static bool allocno_p;

-/* Number of elements in arrays `in_inc_dec' and `costs'.  */
+/* Number of elements in array `costs'.  */
 static int cost_elements_num;

-#ifdef FORBIDDEN_INC_DEC_CLASSES
-/* Indexed by n, is TRUE if allocno or pseudo with number N is used in
-   an auto-inc or auto-dec context.  */
-static bool *in_inc_dec;
-#endif
-
 /* The `costs' struct records the cost of using hard registers of each
    class considered for the calculation and of using memory for each
    allocno or pseudo.  */
@@ -1135,13 +1129,7 @@ record_address_regs (enum machine_mode m
     case PRE_DEC:
       /* Double the importance of an allocno that is incremented or
 	 decremented, since it would take two extra insns if it ends
-	 up in the wrong place.  If the operand is a pseudo-register,
-	 show it is being used in an INC_DEC context.  */
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-      if (REG_P (XEXP (x, 0))
-	  && REGNO (XEXP (x, 0)) >= FIRST_PSEUDO_REGISTER)
-	in_inc_dec[COST_INDEX (REGNO (XEXP (x, 0)))] = true;
-#endif
+	 up in the wrong place.  */
       record_address_regs (mode, XEXP (x, 0), 0, code, SCRATCH, 2 * scale);
       break;

@@ -1380,9 +1368,6 @@ print_allocno_costs (FILE *f)
 	{
 	  rclass = cost_classes[k];
 	  if (contains_reg_of_mode[rclass][PSEUDO_REGNO_MODE (regno)]
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-	      && (! in_inc_dec[i] || ! forbidden_inc_dec_class[rclass])
-#endif
 #ifdef CANNOT_CHANGE_MODE_CLASS
 	      && ! invalid_mode_change_p (regno, (enum reg_class) rclass)
 #endif
@@ -1425,9 +1410,6 @@ print_pseudo_costs (FILE *f)
 	{
 	  rclass = cost_classes[k];
 	  if (contains_reg_of_mode[rclass][PSEUDO_REGNO_MODE (regno)]
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-	      && (! in_inc_dec[regno] || ! forbidden_inc_dec_class[rclass])
-#endif
 #ifdef CANNOT_CHANGE_MODE_CLASS
 	      && ! invalid_mode_change_p (regno, (enum reg_class) rclass)
 #endif
@@ -1477,9 +1459,6 @@ find_costs_and_classes (FILE *dump_file)
   enum reg_class *regno_best_class;

   init_recog ();
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-  in_inc_dec = ira_allocate (sizeof (bool) * cost_elements_num);
-#endif /* FORBIDDEN_INC_DEC_CLASSES */
   regno_best_class
     = (enum reg_class *) ira_allocate (max_reg_num ()
 				       * sizeof (enum reg_class));
@@ -1544,9 +1523,6 @@ find_costs_and_classes (FILE *dump_file)
       /* Zero out our accumulation of the cost of each class for each
 	 allocno.  */
       memset (costs, 0, cost_elements_num * struct_costs_size);
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-      memset (in_inc_dec, 0, cost_elements_num * sizeof (bool));
-#endif

       if (allocno_p)
 	{
@@ -1578,9 +1554,6 @@ find_costs_and_classes (FILE *dump_file)
 	  ira_loop_tree_node_t parent;
 	  int best_cost, allocno_cost;
 	  enum reg_class best, alt_class;
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-	  int inc_dec_p = false;
-#endif
 	  cost_classes_t cost_classes_ptr = regno_cost_classes[i];
 	  enum reg_class *cost_classes = cost_classes_ptr->classes;
 	  int *i_costs = temp_costs->cost;
@@ -1591,9 +1564,6 @@ find_costs_and_classes (FILE *dump_file)
 	    {
 	      if (regno_reg_rtx[i] == NULL_RTX)
 		continue;
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-	      inc_dec_p = in_inc_dec[i];
-#endif
 	      memcpy (temp_costs, COSTS (costs, i), struct_costs_size);
 	      i_mem_cost = temp_costs->mem_cost;
 	    }
@@ -1659,10 +1629,6 @@ find_costs_and_classes (FILE *dump_file)
 		    i_mem_cost = INT_MAX;
 		  else
 		    i_mem_cost += add_cost;
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-		  if (in_inc_dec[a_num])
-		    inc_dec_p = true;
-#endif
 		}
 	    }
 	  if (equiv_savings < 0)
@@ -1685,9 +1651,6 @@ find_costs_and_classes (FILE *dump_file)
 	      /* Ignore classes that are too small for this operand or
 		 invalid for an operand that was auto-incremented.  */
 	      if (! contains_reg_of_mode[rclass][PSEUDO_REGNO_MODE (i)]
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-		  || (inc_dec_p && forbidden_inc_dec_class[rclass])
-#endif
 #ifdef CANNOT_CHANGE_MODE_CLASS
 		  || invalid_mode_change_p (i, (enum reg_class) rclass)
 #endif
@@ -1764,9 +1727,6 @@ find_costs_and_classes (FILE *dump_file)
 			 operand or invalid for an operand that was
 			 auto-incremented.  */
 		      if (! contains_reg_of_mode[rclass][PSEUDO_REGNO_MODE (i)]
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-			  || (inc_dec_p && forbidden_inc_dec_class[rclass])
-#endif
 #ifdef CANNOT_CHANGE_MODE_CLASS
 			  || invalid_mode_change_p (i, (enum reg_class) rclass)
 #endif
@@ -1813,9 +1773,6 @@ find_costs_and_classes (FILE *dump_file)
 	}
     }
   ira_free (regno_best_class);
-#ifdef FORBIDDEN_INC_DEC_CLASSES
-  ira_free (in_inc_dec);
-#endif
 }



brgds, H-P

  reply	other threads:[~2011-06-10  3:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08 16:49 Hans-Peter Nilsson
2011-06-09 16:24 ` Vladimir Makarov
2011-06-10  3:46   ` Hans-Peter Nilsson [this message]
2011-06-10 13:08     ` Hans-Peter Nilsson
2011-06-10 14:03       ` Vladimir Makarov

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=alpine.BSF.2.00.1106092254551.61896@dair.pair.com \
    --to=hp@bitrange.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=vmakarov@redhat.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).