Patchwork Expect JUMP_TABLE_DATA in NEXT_INSN(label)

login
register
mail settings
Submitter Steven Bosscher
Date Nov. 2, 2013, 12:45 a.m.
Message ID <CABu31nOjo88gqFcDRqav0-r0gU6nw2dZ5g94smwW0XXOu4iTPw@mail.gmail.com>
Download mbox | patch
Permalink /patch/287947/
State New
Headers show

Comments

Steven Bosscher - Nov. 2, 2013, 12:45 a.m.
Hello,

As $SUBJECT. The assert for this has been in place for several months
now without triggering any issues, so I'd like to make this next step
before stage1 is over.

OK for trunk?

Ciao!
Steven
Richard Guenther - Nov. 4, 2013, 11:12 a.m.
On Sat, Nov 2, 2013 at 1:45 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> As $SUBJECT. The assert for this has been in place for several months
> now without triggering any issues, so I'd like to make this next step
> before stage1 is over.
>
> OK for trunk?

Ok.  Can you verify this from some RTL insn verifier (if it not already is).

Thanks,
Richard.

> Ciao!
> Steven

Patch

	* rtlanal.c (tablejump_p): Expect a JUMP_TABLE_DATA to always follow
	immediately after a label for a tablejump pattern.

	* config/arm/arm.c (is_jump_table): Remove.
	(create_fix_barrier): Use tablejump_p instead.
	(arm_reorg): Likewise.
	(thumb1_output_casesi): Expect JUMP_TABLE_DATA to always be NEXT_INSN.
	(thumb2_output_casesi): Likewise.
	* config/aarch64/aarch64.c (aarch64_output_casesi): Likewise.
	* config/sh/sh.md (casesi_worker_1, casesi_worker_2,
	casesi_shift_media, casesi_load_media): Likewise.
	* config/iq2000/iq2000.md: Likewise (in anonymous define_insn).
	* config/microblaze/microblaze.md: Likewise.

Index: rtlanal.c
===================================================================
--- rtlanal.c	(revision 204308)
+++ rtlanal.c	(working copy)
@@ -2742,10 +2742,9 @@  tablejump_p (const_rtx insn, rtx *labelp, rtx *tab
 
   label = JUMP_LABEL (insn);
   if (label != NULL_RTX && !ANY_RETURN_P (label)
-      && (table = next_active_insn (label)) != NULL_RTX
+      && (table = NEXT_INSN (label)) != NULL_RTX
       && JUMP_TABLE_DATA_P (table))
     {
-      gcc_assert (table == NEXT_INSN (label));
       if (labelp)
 	*labelp = label;
       if (tablep)
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 204308)
+++ config/arm/arm.c	(working copy)
@@ -95,13 +95,11 @@  static bool arm_print_operand_punct_valid_p (unsig
 static const char *fp_const_from_val (REAL_VALUE_TYPE *);
 static arm_cc get_arm_condition_code (rtx);
 static HOST_WIDE_INT int_log2 (HOST_WIDE_INT);
-static rtx is_jump_table (rtx);
 static const char *output_multi_immediate (rtx *, const char *, const char *,
 					   int, HOST_WIDE_INT);
 static const char *shift_op (rtx, HOST_WIDE_INT *);
 static struct machine_function *arm_init_machine_status (void);
 static void thumb_exit (FILE *, int);
-static rtx is_jump_table (rtx);
 static HOST_WIDE_INT get_jump_table_size (rtx);
 static Mnode *move_minipool_fix_forward_ref (Mnode *, Mnode *, HOST_WIDE_INT);
 static Mnode *add_minipool_forward_ref (Mfix *);
@@ -15468,23 +15466,6 @@  Mfix * 		minipool_fix_tail;
 /* The fix entry for the current minipool, once it has been placed.  */
 Mfix *		minipool_barrier;
 
-/* Determines if INSN is the start of a jump table.  Returns the end
-   of the TABLE or NULL_RTX.  */
-static rtx
-is_jump_table (rtx insn)
-{
-  rtx table;
-
-  if (jump_to_label_p (insn)
-      && ((table = next_active_insn (JUMP_LABEL (insn)))
-	  == next_active_insn (insn))
-      && table != NULL
-      && JUMP_TABLE_DATA_P (table))
-    return table;
-
-  return NULL_RTX;
-}
-
 #ifndef JUMP_TABLES_IN_TEXT_SECTION
 #define JUMP_TABLES_IN_TEXT_SECTION 0
 #endif
@@ -16093,8 +16074,7 @@  create_fix_barrier (Mfix *fix, HOST_WIDE_INT max_a
 	count += get_attr_length (from);
 
       /* If there is a jump table, add its length.  */
-      tmp = is_jump_table (from);
-      if (tmp != NULL)
+      if (tablejump_p (from, NULL, &tmp))
 	{
 	  count += get_jump_table_size (tmp);
 
@@ -16700,7 +16680,7 @@  arm_reorg (void)
 
 	  /* If the insn is a vector jump, add the size of the table
 	     and skip the table.  */
-	  if ((table = is_jump_table (insn)) != NULL)
+	  if (tablejump_p (insn, NULL, &table))
 	    {
 	      address += get_jump_table_size (table);
 	      insn = table;
@@ -28610,7 +28590,7 @@  arm_output_iwmmxt_tinsr (rtx *operands)
 const char *
 thumb1_output_casesi (rtx *operands)
 {
-  rtx diff_vec = PATTERN (next_active_insn (operands[0]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[0]));
 
   gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
 
@@ -28633,7 +28613,7 @@  thumb1_output_casesi (rtx *operands)
 const char *
 thumb2_output_casesi (rtx *operands)
 {
-  rtx diff_vec = PATTERN (next_active_insn (operands[2]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[2]));
 
   gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
 
Index: config/aarch64/aarch64.c
===================================================================
--- config/aarch64/aarch64.c	(revision 204308)
+++ config/aarch64/aarch64.c	(working copy)
@@ -4329,7 +4329,7 @@  aarch64_output_casesi (rtx *operands)
 {
   char buf[100];
   char label[100];
-  rtx diff_vec = PATTERN (next_active_insn (operands[2]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[2]));
   int index;
   static const char *const patterns[4][2] =
   {
Index: config/sh/sh.md
===================================================================
--- config/sh/sh.md	(revision 204308)
+++ config/sh/sh.md	(working copy)
@@ -10827,7 +10827,7 @@  label:
    (clobber (match_scratch:SI 3 "=X,1"))]
   "TARGET_SH1"
 {
-  rtx diff_vec = PATTERN (next_active_insn (operands[2]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[2]));
 
   gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
 
@@ -10861,7 +10861,7 @@  label:
    (clobber (match_operand:SI 4 "" "=X,1"))]
   "TARGET_SH2 && reload_completed && flag_pic"
 {
-  rtx diff_vec = PATTERN (next_active_insn (operands[2]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[2]));
   gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
 
   switch (GET_MODE (diff_vec))
@@ -10899,7 +10899,7 @@  label:
 		    UNSPEC_CASESI)))]
   "TARGET_SHMEDIA"
 {
-  rtx diff_vec = PATTERN (next_active_insn (operands[2]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[2]));
 
   gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
 
@@ -10926,7 +10926,7 @@  label:
 		      (label_ref:DI (match_operand 3 "" ""))] UNSPEC_CASESI)))]
   "TARGET_SHMEDIA"
 {
-  rtx diff_vec = PATTERN (next_active_insn (operands[3]));
+  rtx diff_vec = PATTERN (NEXT_INSN (operands[3]));
 
   gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
 
Index: config/iq2000/iq2000.md
===================================================================
--- config/iq2000/iq2000.md	(revision 204308)
+++ config/iq2000/iq2000.md	(working copy)
@@ -1398,9 +1398,8 @@ 
 	(plus:SI (match_operand:SI 0 "register_operand" "d")
 		 (label_ref:SI (match_operand 1 "" ""))))
    (use (label_ref:SI (match_dup 1)))]
-  "!(Pmode == DImode) && next_active_insn (insn) != 0
-   && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
-   && PREV_INSN (next_active_insn (insn)) == operands[1]"
+  "!(Pmode == DImode) && NEXT_INSN (operands[1]) != 0
+   && GET_CODE (PATTERN (NEXT_INSN (operands[1]))) == ADDR_DIFF_VEC"
   "*
 {
   return \"j\\t%0\";
Index: config/microblaze/microblaze.md
===================================================================
--- config/microblaze/microblaze.md	(revision 204308)
+++ config/microblaze/microblaze.md	(working copy)
@@ -1798,9 +1798,8 @@ 
 	(plus:SI (match_operand:SI 0 "register_operand" "d")
 		 (label_ref:SI (match_operand 1 "" ""))))
   (use (label_ref:SI (match_dup 1)))]
- "next_active_insn (insn) != 0
-  && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
-  && PREV_INSN (next_active_insn (insn)) == operands[1]
+ "NEXT_INSN (operands[1]) != 0
+  && GET_CODE (PATTERN (NEXT_INSN (operands[1]))) == ADDR_DIFF_VEC
   && flag_pic"
   {
     output_asm_insn ("addk\t%0,%0,r20",operands);