cse.c (check_for_label_ref): Move earlier in file.
authorRichard Sandiford <rdsandiford@googlemail.com>
Thu, 28 Aug 2014 06:22:33 +0000 (06:22 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 28 Aug 2014 06:22:33 +0000 (06:22 +0000)
gcc/
* cse.c (check_for_label_ref): Move earlier in file.  Turn from
being a for_each_rtx callback to being a function that examines
each subrtx itself.
(cse_extended_basic_block): Update call accordingly.

From-SVN: r214629

gcc/ChangeLog
gcc/cse.c

index 3fe52d50be8e5bfc1a7ff50fab344652de66c655..e096c5e8cee8535ba240b65a541b8f9a50f2fd08 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-28  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * cse.c (check_for_label_ref): Move earlier in file.  Turn from
+       being a for_each_rtx callback to being a function that examines
+       each subrtx itself.
+       (cse_extended_basic_block): Update call accordingly.
+
 2014-08-28  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * cse.c (check_dependence_data): Delete.
index 3557894dde94a2784220fc374d2eb005601ebf00..a6c9e5c5a030afb50db9e0d18b7eddf82fa0799e 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -596,7 +596,6 @@ static void invalidate_from_clobbers (rtx_insn *);
 static void invalidate_from_sets_and_clobbers (rtx_insn *);
 static rtx cse_process_notes (rtx, rtx, bool *);
 static void cse_extended_basic_block (struct cse_basic_block_data *);
-static int check_for_label_ref (rtx *, void *);
 extern void dump_class (struct table_elt*);
 static void get_cse_reg_info_1 (unsigned int regno);
 static struct cse_reg_info * get_cse_reg_info (unsigned int regno);
@@ -6366,6 +6365,32 @@ cse_prescan_path (struct cse_basic_block_data *data)
   data->nsets = nsets;
 }
 \f
+/* Return true if the pattern of INSN uses a LABEL_REF for which
+   there isn't a REG_LABEL_OPERAND note.  */
+
+static bool
+check_for_label_ref (rtx_insn *insn)
+{
+  /* If this insn uses a LABEL_REF and there isn't a REG_LABEL_OPERAND
+     note for it, we must rerun jump since it needs to place the note.  If
+     this is a LABEL_REF for a CODE_LABEL that isn't in the insn chain,
+     don't do this since no REG_LABEL_OPERAND will be added.  */
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, PATTERN (insn), ALL)
+    {
+      const_rtx x = *iter;
+      if (GET_CODE (x) == LABEL_REF
+         && !LABEL_REF_NONLOCAL_P (x)
+         && (!JUMP_P (insn)
+             || !label_is_jump_target_p (XEXP (x, 0), insn))
+         && LABEL_P (XEXP (x, 0))
+         && INSN_UID (XEXP (x, 0)) != 0
+         && !find_reg_note (insn, REG_LABEL_OPERAND, XEXP (x, 0)))
+       return true;
+    }
+  return false;
+}
+
 /* Process a single extended basic block described by EBB_DATA.  */
 
 static void
@@ -6436,8 +6461,7 @@ cse_extended_basic_block (struct cse_basic_block_data *ebb_data)
              /* If we haven't already found an insn where we added a LABEL_REF,
                 check this one.  */
              if (INSN_P (insn) && !recorded_label_ref
-                 && for_each_rtx (&PATTERN (insn), check_for_label_ref,
-                                  (void *) insn))
+                 && check_for_label_ref (insn))
                recorded_label_ref = true;
 
 #ifdef HAVE_cc0
@@ -6630,28 +6654,6 @@ cse_main (rtx_insn *f ATTRIBUTE_UNUSED, int nregs)
     return 0;
 }
 \f
-/* Called via for_each_rtx to see if an insn is using a LABEL_REF for
-   which there isn't a REG_LABEL_OPERAND note.
-   Return one if so.  DATA is the insn.  */
-
-static int
-check_for_label_ref (rtx *rtl, void *data)
-{
-  rtx_insn *insn = (rtx_insn *) data;
-
-  /* If this insn uses a LABEL_REF and there isn't a REG_LABEL_OPERAND
-     note for it, we must rerun jump since it needs to place the note.  If
-     this is a LABEL_REF for a CODE_LABEL that isn't in the insn chain,
-     don't do this since no REG_LABEL_OPERAND will be added.  */
-  return (GET_CODE (*rtl) == LABEL_REF
-         && ! LABEL_REF_NONLOCAL_P (*rtl)
-         && (!JUMP_P (insn)
-             || !label_is_jump_target_p (XEXP (*rtl, 0), insn))
-         && LABEL_P (XEXP (*rtl, 0))
-         && INSN_UID (XEXP (*rtl, 0)) != 0
-         && ! find_reg_note (insn, REG_LABEL_OPERAND, XEXP (*rtl, 0)));
-}
-\f
 /* Count the number of times registers are used (not set) in X.
    COUNTS is an array in which we accumulate the count, INCR is how much
    we count each register usage.