public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Use JUMP_TABLE_DATA_P instead of JUMP_P and GET_CODE tests
@ 2013-03-23 16:16 Steven Bosscher
  2013-03-27 23:17 ` Steven Bosscher
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Bosscher @ 2013-03-23 16:16 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jeff Law

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

Hello,

This patch replaces all tests I could find, where the code is looking
for jump table data with GET_CODE(..)=ADDR_VEC and similar with
JUMP_TABLE_DATA_P tests.

Most replacements are mechanical, but a few are not:

* The code in s390.c looked odd, I think the replacement code is
easier to follow.

* The changed in bfin.c and a few other places assume that ADDR_VEC
and ADDR_DIFF_VEC can only appear as tablejump data. This appears to
be assumed in many other places in the compiler (although AFAICT it's
not documented as such) and it looks like the authors of the changed
code simply omitted the JUMP_P test before looking at the pattern for
an ADDR_VEC/ADDR_DIFF_VEC.

BTW if ADDR_VEC/ADDR_DIFF_VEC really only appear in JUMP_TABLE_DATA_P
insns then tests for these codes can be removed in all places where
the insn being looked at must be in a basic block. That's almost all
places in the middle-end proper (especially as case labels) and I
intend to clean that up in a follow-up patch.

But first...

Bootstrapped&tested on powerpc64-unknown-linux-gnu and on
ia64-unknown-linux-gnu.
OK for trunk?

Ciao!
Steven

[-- Attachment #2: use_JUMP_TABLE_DATA_P.diff --]
[-- Type: application/octet-stream, Size: 24455 bytes --]

	* cfgbuild.c (inside_basic_block_p): Use JUMP_TABLE_DATA_P in lieu
	of tests for JUMP_P and a ADDR_DIFF_VEC or ADDR_VEC pattern.
	(control_flow_insn_p): Likewise.
	* cfgrtl.c (duplicate_insn_chain): Likewise.
	* final.c (get_attr_length_1): Likewise.
	(shorten_branches): Likewise.
	(final_scan_insn): Likewise.
	* function.c (instantiate_virtual_regs): Likewise.
	* gcse.c (insert_insn_end_basic_block): Likewise.
	* ira-costs.c (scan_one_insn): Likewise.
	* lra-eliminations.c (eliminate_regs_in_insn): Likewise.
	* lra.c (check_rtl): Likewise.
	* reload1.c (elimination_costs_in_insn): Likewise.
	* reorg.c (follow_jumps): Likewise.

	* config/arm/arm.c (is_jump_table): Use JUMP_TABLE_DATA_P in lieu
	of tests for JUMP_P and a ADDR_DIFF_VEC or ADDR_VEC pattern.
	(thumb_far_jump_used_p): Likewise.
	* config/bfin/bfin.c (workaround_rts_anomaly): Likewise.
	(workaround_speculation): Likewise.
	(add_sched_insns_for_speculation): Likewise.
	* config/c6x/c6x.c (reorg_emit_nops): Likewise.
	* config/frv/frv.c (frv_function_contains_far_jump): Likewise.
	(frv_for_each_packet): Likewise.
	* config/i386/i386.c (ix86_avoid_jump_mispredicts): Likewise.
	* config/ia64/ia64.c (emit_all_insn_group_barriers): Likewise.
	(final_emit_insn_group_barriers): Likewise.
	* config/m32r/m32r.c (m32r_is_insn): Likewise.
	* config/mips/mips.c (USEFUL_INSN_P): Likewise.
	(mips16_insn_length): Likewise.
	* config/pa/pa.c (pa_reorg): Likewise.
	(pa_combine_instructions): Likewise.
	* config/rs6000/rs6000.c (rs6000_invalid_within_doloop): Likewise.
	* config/s390/s390.c (addr_generation_dependency_p): Likewise.
	(s390_chunkify_start): Likewise.
	* config/sh/sh.c (fixup_addr_diff_vecs): Likewise.
	(sh_reorg): Likewise.
	(split_branches): Likewise.

	* config/spu/spu.c (get_branch_target): Simplify logic using
	JUMP_TABLE_DATA_P.

Index: cfgbuild.c
===================================================================
--- cfgbuild.c	(revision 197004)
+++ cfgbuild.c	(working copy)
@@ -51,13 +51,10 @@ inside_basic_block_p (const_rtx insn)
     case CODE_LABEL:
       /* Avoid creating of basic block for jumptables.  */
       return (NEXT_INSN (insn) == 0
-	      || !JUMP_P (NEXT_INSN (insn))
-	      || (GET_CODE (PATTERN (NEXT_INSN (insn))) != ADDR_VEC
-		  && GET_CODE (PATTERN (NEXT_INSN (insn))) != ADDR_DIFF_VEC));
+	      || ! JUMP_TABLE_DATA_P (insn));
 
     case JUMP_INSN:
-      return (GET_CODE (PATTERN (insn)) != ADDR_VEC
-	      && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC);
+      return (! JUMP_TABLE_DATA_P (insn));
 
     case CALL_INSN:
     case INSN:
@@ -88,8 +85,7 @@ control_flow_insn_p (const_rtx insn)
 
     case JUMP_INSN:
       /* Jump insn always causes control transfer except for tablejumps.  */
-      return (GET_CODE (PATTERN (insn)) != ADDR_VEC
-	      && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC);
+      return (! JUMP_TABLE_DATA_P (insn));
 
     case CALL_INSN:
       /* Noreturn and sibling call instructions terminate the basic blocks
Index: cfgrtl.c
===================================================================
--- cfgrtl.c	(revision 197004)
+++ cfgrtl.c	(working copy)
@@ -3627,8 +3627,7 @@ duplicate_insn_chain (rtx from, rtx to)
 	  /* Avoid copying of dispatch tables.  We never duplicate
 	     tablejumps, so this can hit only in case the table got
 	     moved far from original jump.  */
-	  if (GET_CODE (PATTERN (insn)) == ADDR_VEC
-	      || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
+	  if (JUMP_TABLE_DATA_P (insn))
 	    {
 	      /* Avoid copying following barrier as well if any
 		 (and debug insns in between).  */
Index: final.c
===================================================================
--- final.c	(revision 197004)
+++ final.c	(working copy)
@@ -396,7 +396,7 @@ get_attr_length_1 (rtx insn, int (*fallback_fn) (r
 
       case JUMP_INSN:
 	body = PATTERN (insn);
-	if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
+	if (JUMP_TABLE_DATA_P (insn))
 	  {
 	    /* Alignment is machine-dependent and should be handled by
 	       ADDR_VEC_ALIGN.  */
@@ -1020,7 +1020,7 @@ shorten_branches (rtx first)
 	  int min_align;
 	  addr_diff_vec_flags flags;
 
-	  if (!JUMP_P (insn)
+	  if (! JUMP_TABLE_DATA_P (insn)
 	      || GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
 	    continue;
 	  pat = PATTERN (insn);
@@ -1094,7 +1094,7 @@ shorten_branches (rtx first)
 	continue;
 
       body = PATTERN (insn);
-      if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
+      if (JUMP_TABLE_DATA_P (insn))
 	{
 	  /* This only takes room if read-only data goes into the text
 	     section.  */
@@ -1230,7 +1230,8 @@ shorten_branches (rtx first)
 	  INSN_ADDRESSES (uid) = insn_current_address;
 
 #ifdef CASE_VECTOR_SHORTEN_MODE
-	  if (optimize && JUMP_P (insn)
+	  if (optimize
+	      && JUMP_TABLE_DATA_P (insn)
 	      && GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
 	    {
 	      rtx body = PATTERN (insn);
@@ -2404,7 +2405,7 @@ final_scan_insn (rtx insn, FILE *file, int optimiz
 	/* Detect insns that are really jump-tables
 	   and output them as such.  */
 
-	if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
+        if (JUMP_TABLE_DATA_P (insn))
 	  {
 #if !(defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC))
 	    int vlen, idx;
Index: function.c
===================================================================
--- function.c	(revision 197004)
+++ function.c	(working copy)
@@ -1915,10 +1915,9 @@ instantiate_virtual_regs (void)
       {
 	/* These patterns in the instruction stream can never be recognized.
 	   Fortunately, they shouldn't contain virtual registers either.  */
-	if (GET_CODE (PATTERN (insn)) == USE
+        if (JUMP_TABLE_DATA_P (insn)
+	    || GET_CODE (PATTERN (insn)) == USE
 	    || GET_CODE (PATTERN (insn)) == CLOBBER
-	    || GET_CODE (PATTERN (insn)) == ADDR_VEC
-	    || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
 	    || GET_CODE (PATTERN (insn)) == ASM_INPUT)
 	  continue;
 	else if (DEBUG_INSN_P (insn))
Index: gcse.c
===================================================================
--- gcse.c	(revision 197004)
+++ gcse.c	(working copy)
@@ -2150,8 +2150,7 @@ insert_insn_end_basic_block (struct expr *expr, ba
       /* If this is a jump table, then we can't insert stuff here.  Since
 	 we know the previous real insn must be the tablejump, we insert
 	 the new instruction just before the tablejump.  */
-      if (GET_CODE (PATTERN (insn)) == ADDR_VEC
-	  || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
+      if (JUMP_TABLE_DATA_P (insn))
 	insn = prev_active_insn (insn);
 
 #ifdef HAVE_cc0
Index: ira-costs.c
===================================================================
--- ira-costs.c	(revision 197004)
+++ ira-costs.c	(working copy)
@@ -1269,12 +1269,12 @@ scan_one_insn (rtx insn)
   int i, k;
   bool counted_mem;
 
-  if (!NONDEBUG_INSN_P (insn))
+  if (!NONDEBUG_INSN_P (insn)
+      || JUMP_TABLE_DATA_P (insn))
     return insn;
 
   pat_code = GET_CODE (PATTERN (insn));
-  if (pat_code == USE || pat_code == CLOBBER || pat_code == ASM_INPUT
-      || pat_code == ADDR_VEC || pat_code == ADDR_DIFF_VEC)
+  if (pat_code == USE || pat_code == CLOBBER || pat_code == ASM_INPUT)
     return insn;
 
   counted_mem = false;
Index: lra-eliminations.c
===================================================================
--- lra-eliminations.c	(revision 197004)
+++ lra-eliminations.c	(working copy)
@@ -767,10 +767,9 @@ eliminate_regs_in_insn (rtx insn, bool replace_p)
 
   if (icode < 0 && asm_noperands (PATTERN (insn)) < 0 && ! DEBUG_INSN_P (insn))
     {
-      lra_assert (GET_CODE (PATTERN (insn)) == USE
+      lra_assert (JUMP_TABLE_DATA_P (insn)
+		  || GET_CODE (PATTERN (insn)) == USE
 		  || GET_CODE (PATTERN (insn)) == CLOBBER
-		  || GET_CODE (PATTERN (insn)) == ADDR_VEC
-		  || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
 		  || GET_CODE (PATTERN (insn)) == ASM_INPUT);
       return;
     }
Index: lra.c
===================================================================
--- lra.c	(revision 197004)
+++ lra.c	(working copy)
@@ -1997,10 +1997,9 @@ check_rtl (bool final_p)
   FOR_EACH_BB (bb)
     FOR_BB_INSNS (bb, insn)
     if (NONDEBUG_INSN_P (insn)
+	&& ! JUMP_TABLE_DATA_P (insn)
 	&& GET_CODE (PATTERN (insn)) != USE
 	&& GET_CODE (PATTERN (insn)) != CLOBBER
-	&& GET_CODE (PATTERN (insn)) != ADDR_VEC
-	&& GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC
 	&& GET_CODE (PATTERN (insn)) != ASM_INPUT)
       {
 	if (final_p)
Index: reload1.c
===================================================================
--- reload1.c	(revision 197004)
+++ reload1.c	(working copy)
@@ -3234,10 +3234,9 @@ eliminate_regs_in_insn (rtx insn, int replace)
 
   if (! insn_is_asm && icode < 0)
     {
-      gcc_assert (GET_CODE (PATTERN (insn)) == USE
+      gcc_assert (JUMP_TABLE_DATA_P (insn)
+		  || GET_CODE (PATTERN (insn)) == USE
 		  || GET_CODE (PATTERN (insn)) == CLOBBER
-		  || GET_CODE (PATTERN (insn)) == ADDR_VEC
-		  || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
 		  || GET_CODE (PATTERN (insn)) == ASM_INPUT
 		  || DEBUG_INSN_P (insn));
       if (DEBUG_INSN_P (insn))
@@ -3645,10 +3644,9 @@ elimination_costs_in_insn (rtx insn)
 
   if (! insn_is_asm && icode < 0)
     {
-      gcc_assert (GET_CODE (PATTERN (insn)) == USE
+      gcc_assert (JUMP_TABLE_DATA_P (insn)
+		  || GET_CODE (PATTERN (insn)) == USE
 		  || GET_CODE (PATTERN (insn)) == CLOBBER
-		  || GET_CODE (PATTERN (insn)) == ADDR_VEC
-		  || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
 		  || GET_CODE (PATTERN (insn)) == ASM_INPUT
 		  || DEBUG_INSN_P (insn));
       return;
Index: reorg.c
===================================================================
--- reorg.c	(revision 197004)
+++ reorg.c	(working copy)
@@ -2339,9 +2339,7 @@ follow_jumps (rtx label, rtx jump, bool *crossing)
       if (ANY_RETURN_P (this_label))
 	return this_label;
       tem = next_active_insn (this_label);
-      if (tem
-	  && (GET_CODE (PATTERN (tem)) == ADDR_VEC
-	      || GET_CODE (PATTERN (tem)) == ADDR_DIFF_VEC))
+      if (tem && JUMP_TABLE_DATA_P (tem))
 	break;
 
       if (!targetm.can_follow_jump (jump, insn))
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 197004)
+++ config/arm/arm.c	(working copy)
@@ -12813,9 +12813,7 @@ is_jump_table (rtx insn)
       && ((table = next_real_insn (JUMP_LABEL (insn)))
 	  == next_real_insn (insn))
       && table != NULL
-      && JUMP_P (table)
-      && (GET_CODE (PATTERN (table)) == ADDR_VEC
-	  || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC))
+      && JUMP_TABLE_DATA_P (table))
     return table;
 
   return NULL_RTX;
@@ -22647,8 +22645,7 @@ thumb_far_jump_used_p (void)
     {
       if (JUMP_P (insn)
 	  /* Ignore tablejump patterns.  */
-	  && GET_CODE (PATTERN (insn)) != ADDR_VEC
-	  && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC
+	  && ! JUMP_TABLE_DATA_P (insn)
 	  && get_attr_far_jump (insn) == FAR_JUMP_YES
 	  )
 	{
Index: config/bfin/bfin.c
===================================================================
--- config/bfin/bfin.c	(revision 197005)
+++ config/bfin/bfin.c	(working copy)
@@ -4084,12 +4084,15 @@ workaround_rts_anomaly (void)
       if (NOTE_P (insn) || LABEL_P (insn))
 	continue;
 
+      if (JUMP_TABLE_DATA_P (insn))
+	continue;
+
       if (first_insn == NULL_RTX)
 	first_insn = insn;
       pat = PATTERN (insn);
       if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER
-	  || GET_CODE (pat) == ASM_INPUT || GET_CODE (pat) == ADDR_VEC
-	  || GET_CODE (pat) == ADDR_DIFF_VEC || asm_noperands (pat) >= 0)
+	  || GET_CODE (pat) == ASM_INPUT
+	  || asm_noperands (pat) >= 0)
 	continue;
 
       if (CALL_P (insn))
@@ -4277,6 +4280,8 @@ workaround_speculation (void)
       
       if (NOTE_P (insn) || BARRIER_P (insn))
 	continue;
+      if (JUMP_TABLE_DATA_P (insn))
+	continue;
 
       if (LABEL_P (insn))
 	{
@@ -4285,8 +4290,7 @@ workaround_speculation (void)
 	}
 
       pat = PATTERN (insn);
-      if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER
-	  || GET_CODE (pat) == ADDR_VEC || GET_CODE (pat) == ADDR_DIFF_VEC)
+      if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER)
 	continue;
       
       if (GET_CODE (pat) == ASM_INPUT || asm_noperands (pat) >= 0)
@@ -4434,10 +4438,13 @@ workaround_speculation (void)
 	      if (NOTE_P (target) || BARRIER_P (target) || LABEL_P (target))
 		continue;
 
+	      if (JUMP_TABLE_DATA_P (target))
+		continue;
+
 	      pat = PATTERN (target);
 	      if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER
-		  || GET_CODE (pat) == ASM_INPUT || GET_CODE (pat) == ADDR_VEC
-		  || GET_CODE (pat) == ADDR_DIFF_VEC || asm_noperands (pat) >= 0)
+		  || GET_CODE (pat) == ASM_INPUT
+		  || asm_noperands (pat) >= 0)
 		continue;
 
 	      if (NONDEBUG_INSN_P (target))
@@ -4510,11 +4517,13 @@ add_sched_insns_for_speculation (void)
 
       if (NOTE_P (insn) || BARRIER_P (insn) || LABEL_P (insn))
 	continue;
+      if (JUMP_TABLE_DATA_P (insn))
+	continue;
 
       pat = PATTERN (insn);
       if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER
-	  || GET_CODE (pat) == ASM_INPUT || GET_CODE (pat) == ADDR_VEC
-	  || GET_CODE (pat) == ADDR_DIFF_VEC || asm_noperands (pat) >= 0)
+	  || GET_CODE (pat) == ASM_INPUT
+	  || asm_noperands (pat) >= 0)
 	continue;
 
       if (JUMP_P (insn))
Index: config/c6x/c6x.c
===================================================================
--- config/c6x/c6x.c	(revision 197005)
+++ config/c6x/c6x.c	(working copy)
@@ -5052,9 +5052,7 @@ reorg_emit_nops (rtx *call_labels)
 	  || GET_CODE (PATTERN (insn)) == USE
 	  || GET_CODE (PATTERN (insn)) == CLOBBER
 	  || shadow_or_blockage_p (insn)
-	  || (JUMP_P (insn)
-	      && (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
-		  || GET_CODE (PATTERN (insn)) == ADDR_VEC)))
+	  || JUMP_TABLE_DATA_P (insn))
 	goto next_insn;
 
       if (!c6x_flag_schedule_insns2)
Index: config/frv/frv.c
===================================================================
--- config/frv/frv.c	(revision 197005)
+++ config/frv/frv.c	(working copy)
@@ -1410,8 +1410,7 @@ frv_function_contains_far_jump (void)
   while (insn != NULL
 	 && !(JUMP_P (insn)
 	      /* Ignore tablejump patterns.  */
-	      && GET_CODE (PATTERN (insn)) != ADDR_VEC
-	      && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC
+	      && ! JUMP_TABLE_DATA_P (insn)
 	      && get_attr_far_jump (insn) == FAR_JUMP_YES))
     insn = NEXT_INSN (insn);
   return (insn != NULL);
@@ -7481,13 +7480,11 @@ frv_for_each_packet (void (*handle_packet) (void))
 	  frv_start_packet_block ();
 	}
 
-      if (INSN_P (insn))
+      if (INSN_P (insn) && ! JUMP_TABLE_DATA_P (insn))
 	switch (GET_CODE (PATTERN (insn)))
 	  {
 	  case USE:
 	  case CLOBBER:
-	  case ADDR_VEC:
-	  case ADDR_DIFF_VEC:
 	    break;
 
 	  default:
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 197004)
+++ config/i386/i386.c	(working copy)
@@ -35205,8 +35205,7 @@ ix86_avoid_jump_mispredicts (void)
 		{
 		  start = NEXT_INSN (start);
 		  if ((JUMP_P (start)
-		       && GET_CODE (PATTERN (start)) != ADDR_VEC
-		       && GET_CODE (PATTERN (start)) != ADDR_DIFF_VEC)
+		       && ! JUMP_TABLE_DATA_P (start))
 		      || CALL_P (start))
 		    njumps--, isjump = 1;
 		  else
@@ -35223,8 +35222,7 @@ ix86_avoid_jump_mispredicts (void)
 	fprintf (dump_file, "Insn %i estimated to %i bytes\n",
 		 INSN_UID (insn), min_size);
       if ((JUMP_P (insn)
-	   && GET_CODE (PATTERN (insn)) != ADDR_VEC
-	   && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
+	   && ! JUMP_TABLE_DATA_P (insn))
 	  || CALL_P (insn))
 	njumps++;
       else
@@ -35234,8 +35232,7 @@ ix86_avoid_jump_mispredicts (void)
 	{
 	  start = NEXT_INSN (start);
 	  if ((JUMP_P (start)
-	       && GET_CODE (PATTERN (start)) != ADDR_VEC
-	       && GET_CODE (PATTERN (start)) != ADDR_DIFF_VEC)
+	       && ! JUMP_TABLE_DATA_P (start))
 	      || CALL_P (start))
 	    njumps--, isjump = 1;
 	  else
Index: config/ia64/ia64.c
===================================================================
--- config/ia64/ia64.c	(revision 197005)
+++ config/ia64/ia64.c	(working copy)
@@ -6987,8 +6987,7 @@ emit_all_insn_group_barriers (FILE *dump ATTRIBUTE
 
 	  if (! last)
 	    continue;
-	  if (JUMP_P (last)
-	      && GET_CODE (PATTERN (last)) == ADDR_DIFF_VEC)
+	  if (JUMP_TABLE_DATA_P (last))
 	    last = prev_active_insn (last);
 	  if (recog_memoized (last) != CODE_FOR_insn_group_barrier)
 	    emit_insn_after (gen_insn_group_barrier (GEN_INT (3)), last);
@@ -9376,8 +9375,7 @@ final_emit_insn_group_barriers (FILE *dump ATTRIBU
 
 	  if (! last)
 	    continue;
-	  if (JUMP_P (last)
-	      && GET_CODE (PATTERN (last)) == ADDR_DIFF_VEC)
+	  if (JUMP_TABLE_DATA_P (last))
 	    last = prev_active_insn (last);
 	  if (recog_memoized (last) != CODE_FOR_insn_group_barrier)
 	    emit_insn_after (gen_insn_group_barrier (GEN_INT (3)), last);
Index: config/m32r/m32r.c
===================================================================
--- config/m32r/m32r.c	(revision 197004)
+++ config/m32r/m32r.c	(working copy)
@@ -1308,9 +1308,9 @@ static int
 m32r_is_insn (rtx insn)
 {
   return (NONDEBUG_INSN_P (insn)
+	  && ! JUMP_TABLE_DATA_P (insn)
 	  && GET_CODE (PATTERN (insn)) != USE
-	  && GET_CODE (PATTERN (insn)) != CLOBBER
-	  && GET_CODE (PATTERN (insn)) != ADDR_VEC);
+	  && GET_CODE (PATTERN (insn)) != CLOBBER);
 }
 
 /* Increase the priority of long instructions so that the
Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c	(revision 197004)
+++ config/mips/mips.c	(working copy)
@@ -95,12 +95,13 @@ along with GCC; see the file COPYING3.  If not see
    : TARGET_64BIT ? 0x100 : 0x400)
 
 /* True if INSN is a mips.md pattern or asm statement.  */
+/* ???	This test exists through the compiler, perhaps it should be
+	moved to rtl.h.  */
 #define USEFUL_INSN_P(INSN)						\
   (NONDEBUG_INSN_P (INSN)						\
+   && ! JUMP_TABLE_DATA_P (INSN)					\
    && GET_CODE (PATTERN (INSN)) != USE					\
-   && GET_CODE (PATTERN (INSN)) != CLOBBER				\
-   && GET_CODE (PATTERN (INSN)) != ADDR_VEC				\
-   && GET_CODE (PATTERN (INSN)) != ADDR_DIFF_VEC)
+   && GET_CODE (PATTERN (INSN)) != CLOBBER)
 
 /* If INSN is a delayed branch sequence, return the first instruction
    in the sequence, otherwise return INSN itself.  */
@@ -14598,7 +14599,7 @@ mips16_emit_constants (struct mips16_constant *con
 static int
 mips16_insn_length (rtx insn)
 {
-  if (JUMP_P (insn))
+  if (JUMP_TABLE_DATA_P (insn))
     {
       rtx body = PATTERN (insn);
       if (GET_CODE (body) == ADDR_VEC)
Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 197005)
+++ config/pa/pa.c	(working copy)
@@ -8997,9 +8997,7 @@ pa_reorg (void)
 	  unsigned int length, i;
 
 	  /* Find an ADDR_VEC or ADDR_DIFF_VEC insn to explode.  */
-	  if (! JUMP_P (insn)
-	      || (GET_CODE (PATTERN (insn)) != ADDR_VEC
-		  && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC))
+	  if (! JUMP_TABLE_DATA_P (insn))
 	    continue;
 
 	  /* Emit marker for the beginning of the branch table.  */
@@ -9056,9 +9054,7 @@ pa_reorg (void)
       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
 	{
 	  /* Find an ADDR_VEC insn.  */
-	  if (! JUMP_P (insn)
-	      || (GET_CODE (PATTERN (insn)) != ADDR_VEC
-		  && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC))
+	  if (! JUMP_TABLE_DATA_P (insn))
 	    continue;
 
 	  /* Now generate markers for the beginning and end of the
@@ -9138,10 +9134,9 @@ pa_combine_instructions (void)
       /* We only care about INSNs, JUMP_INSNs, and CALL_INSNs.
 	 Also ignore any special USE insns.  */
       if ((! NONJUMP_INSN_P (anchor) && ! JUMP_P (anchor) && ! CALL_P (anchor))
+	  || JUMP_TABLE_DATA_P (anchor)
 	  || GET_CODE (PATTERN (anchor)) == USE
-	  || GET_CODE (PATTERN (anchor)) == CLOBBER
-	  || GET_CODE (PATTERN (anchor)) == ADDR_VEC
-	  || GET_CODE (PATTERN (anchor)) == ADDR_DIFF_VEC)
+	  || GET_CODE (PATTERN (anchor)) == CLOBBER)
 	continue;
 
       anchor_attr = get_attr_pa_combine_type (anchor);
@@ -9165,8 +9160,7 @@ pa_combine_instructions (void)
 
 	      /* Anything except a regular INSN will stop our search.  */
 	      if (! NONJUMP_INSN_P (floater)
-		  || GET_CODE (PATTERN (floater)) == ADDR_VEC
-		  || GET_CODE (PATTERN (floater)) == ADDR_DIFF_VEC)
+		  || JUMP_TABLE_DATA_P (floater))
 		{
 		  floater = NULL_RTX;
 		  break;
@@ -9227,8 +9221,7 @@ pa_combine_instructions (void)
 
 		  /* Anything except a regular INSN will stop our search.  */
 		  if (! NONJUMP_INSN_P (floater)
-		      || GET_CODE (PATTERN (floater)) == ADDR_VEC
-		      || GET_CODE (PATTERN (floater)) == ADDR_DIFF_VEC)
+		      || JUMP_TABLE_DATA_P (floater))
 		    {
 		      floater = NULL_RTX;
 		      break;
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 197005)
+++ config/rs6000/rs6000.c	(working copy)
@@ -18788,9 +18788,7 @@ rs6000_invalid_within_doloop (const_rtx insn)
   if (CALL_P (insn))
     return "Function call in the loop.";
 
-  if (JUMP_P (insn)
-      && (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
-	  || GET_CODE (PATTERN (insn)) == ADDR_VEC))
+  if (JUMP_TABLE_DATA_P (insn))
     return "Computed branch in the loop.";
 
   return NULL;
Index: config/sh/sh.c
===================================================================
--- config/sh/sh.c	(revision 197004)
+++ config/sh/sh.c	(working copy)
@@ -5799,7 +5799,7 @@ fixup_addr_diff_vecs (rtx first)
     {
       rtx vec_lab, pat, prev, prevpat, x, braf_label;
 
-      if (!JUMP_P (insn)
+      if (! JUMP_TABLE_DATA_P (insn)
 	  || GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
 	continue;
       pat = PATTERN (insn);
@@ -6233,7 +6233,7 @@ sh_reorg (void)
 	      num_mova = 0;
 	    }
 	}
-      else if (JUMP_P (insn)
+      else if (JUMP_TABLE_DATA_P (insn)
 	       && GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
 	       && num_mova
 	       /* ??? loop invariant motion can also move a mova out of a
@@ -6496,8 +6496,7 @@ split_branches (rtx first)
       }
     else if (JUMP_P (insn)
 	     /* Don't mess with ADDR_DIFF_VEC */
-	     && (GET_CODE (PATTERN (insn)) == SET
-		 || GET_CODE (PATTERN (insn)) == RETURN))
+	     && ! JUMP_TABLE_DATA_P (insn))
       {
 	enum attr_type type = get_attr_type (insn);
 	if (type == TYPE_CBRANCH)
Index: config/spu/spu.c
===================================================================
--- config/spu/spu.c	(revision 197005)
+++ config/spu/spu.c	(working copy)
@@ -2172,8 +2172,7 @@ get_branch_target (rtx branch)
 	return gen_rtx_REG (SImode, LINK_REGISTER_REGNUM);
 
       /* jump table */
-      if (GET_CODE (PATTERN (branch)) == ADDR_VEC
-	  || GET_CODE (PATTERN (branch)) == ADDR_DIFF_VEC)
+      if (JUMP_TABLE_DATA_P (branch))
 	return 0;
 
      /* ASM GOTOs. */
Index: config/s390/s390.c
===================================================================
--- config/s390/s390.c	(revision 197005)
+++ config/s390/s390.c	(working copy)
@@ -5739,7 +5739,7 @@ addr_generation_dependency_p (rtx dep_rtx, rtx ins
   rtx target, pat;
 
   if (NONJUMP_INSN_P (dep_rtx))
-      dep_rtx = PATTERN (dep_rtx);
+    dep_rtx = PATTERN (dep_rtx);
 
   if (GET_CODE (dep_rtx) == SET)
     {
@@ -7013,11 +7013,7 @@ s390_chunkify_start (void)
 	  && (LABEL_PRESERVE_P (insn) || LABEL_NAME (insn)))
 	{
 	  rtx vec_insn = next_real_insn (insn);
-	  rtx vec_pat = vec_insn && JUMP_P (vec_insn) ?
-			PATTERN (vec_insn) : NULL_RTX;
-	  if (!vec_pat
-	      || !(GET_CODE (vec_pat) == ADDR_VEC
-		   || GET_CODE (vec_pat) == ADDR_DIFF_VEC))
+	  if (! vec_insn || ! JUMP_TABLE_DATA_P (vec_insn))
 	    bitmap_set_bit (far_labels, CODE_LABEL_NUMBER (insn));
 	}
 
@@ -7048,12 +7044,9 @@ s390_chunkify_start (void)
 	      /* Find the jump table used by this casesi jump.  */
 	      rtx vec_label = XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0);
 	      rtx vec_insn = next_real_insn (vec_label);
-	      rtx vec_pat = vec_insn && JUMP_P (vec_insn) ?
-			    PATTERN (vec_insn) : NULL_RTX;
-	      if (vec_pat
-		  && (GET_CODE (vec_pat) == ADDR_VEC
-		      || GET_CODE (vec_pat) == ADDR_DIFF_VEC))
+	      if (vec_insn && JUMP_TABLE_DATA_P (vec_insn))
 		{
+		  rtx vec_pat = PATTERN (vec_insn);
 		  int i, diff_p = GET_CODE (vec_pat) == ADDR_DIFF_VEC;
 
 		  for (i = 0; i < XVECLEN (vec_pat, diff_p); i++)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Use JUMP_TABLE_DATA_P instead of JUMP_P and GET_CODE tests
  2013-03-23 16:16 [patch] Use JUMP_TABLE_DATA_P instead of JUMP_P and GET_CODE tests Steven Bosscher
@ 2013-03-27 23:17 ` Steven Bosscher
  2013-03-28  9:32   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Bosscher @ 2013-03-27 23:17 UTC (permalink / raw)
  To: GCC Patches

*Ping*

On Sat, Mar 23, 2013 at 5:15 PM, Steven Bosscher wrote:
> Hello,
>
> This patch replaces all tests I could find, where the code is looking
> for jump table data with GET_CODE(..)=ADDR_VEC and similar with
> JUMP_TABLE_DATA_P tests.
>
> Most replacements are mechanical, but a few are not:
>
> * The code in s390.c looked odd, I think the replacement code is
> easier to follow.
>
> * The changed in bfin.c and a few other places assume that ADDR_VEC
> and ADDR_DIFF_VEC can only appear as tablejump data. This appears to
> be assumed in many other places in the compiler (although AFAICT it's
> not documented as such) and it looks like the authors of the changed
> code simply omitted the JUMP_P test before looking at the pattern for
> an ADDR_VEC/ADDR_DIFF_VEC.
>
> BTW if ADDR_VEC/ADDR_DIFF_VEC really only appear in JUMP_TABLE_DATA_P
> insns then tests for these codes can be removed in all places where
> the insn being looked at must be in a basic block. That's almost all
> places in the middle-end proper (especially as case labels) and I
> intend to clean that up in a follow-up patch.
>
> But first...
>
> Bootstrapped&tested on powerpc64-unknown-linux-gnu and on
> ia64-unknown-linux-gnu.
> OK for trunk?
>
> Ciao!
> Steven

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Use JUMP_TABLE_DATA_P instead of JUMP_P and GET_CODE tests
  2013-03-27 23:17 ` Steven Bosscher
@ 2013-03-28  9:32   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2013-03-28  9:32 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches

On Thu, Mar 28, 2013 at 12:16 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> *Ping*

Ok.

Thanks,
Richard.

> On Sat, Mar 23, 2013 at 5:15 PM, Steven Bosscher wrote:
>> Hello,
>>
>> This patch replaces all tests I could find, where the code is looking
>> for jump table data with GET_CODE(..)=ADDR_VEC and similar with
>> JUMP_TABLE_DATA_P tests.
>>
>> Most replacements are mechanical, but a few are not:
>>
>> * The code in s390.c looked odd, I think the replacement code is
>> easier to follow.
>>
>> * The changed in bfin.c and a few other places assume that ADDR_VEC
>> and ADDR_DIFF_VEC can only appear as tablejump data. This appears to
>> be assumed in many other places in the compiler (although AFAICT it's
>> not documented as such) and it looks like the authors of the changed
>> code simply omitted the JUMP_P test before looking at the pattern for
>> an ADDR_VEC/ADDR_DIFF_VEC.
>>
>> BTW if ADDR_VEC/ADDR_DIFF_VEC really only appear in JUMP_TABLE_DATA_P
>> insns then tests for these codes can be removed in all places where
>> the insn being looked at must be in a basic block. That's almost all
>> places in the middle-end proper (especially as case labels) and I
>> intend to clean that up in a follow-up patch.
>>
>> But first...
>>
>> Bootstrapped&tested on powerpc64-unknown-linux-gnu and on
>> ia64-unknown-linux-gnu.
>> OK for trunk?
>>
>> Ciao!
>> Steven

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-28  9:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-23 16:16 [patch] Use JUMP_TABLE_DATA_P instead of JUMP_P and GET_CODE tests Steven Bosscher
2013-03-27 23:17 ` Steven Bosscher
2013-03-28  9:32   ` Richard Biener

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).