From 6121af960d3f36030a6d812f11e47ff3cb6bb7d7 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Thu, 28 Aug 2014 06:24:44 +0000 Subject: [PATCH] gcc/ * sel-sched.c: Include rtl-iter.h (count_occurrences_1): Delete. (count_occurrences_equiv): Turn rtxes into const_rtxes. Use FOR_EACH_SUBRTX rather than for_each_rtx. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214659 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 ++++++ gcc/sel-sched.c | 74 ++++++++++++++++++++------------------------------------- 2 files changed, 33 insertions(+), 48 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 20915cb115c..95c7fb890a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2014-08-28 Richard Sandiford + * sel-sched.c: Include rtl-iter.h + (count_occurrences_1): Delete. + (count_occurrences_equiv): Turn rtxes into const_rtxes. + Use FOR_EACH_SUBRTX rather than for_each_rtx. + +2014-08-28 Richard Sandiford + * rtl.h (tls_referenced_p): Take a const_rtx rather than an rtx. * rtlanal.c (tls_referenced_p_1): Delete. (tls_referenced_p): Take a const_rtx rather than an rtx. diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index d9fe7c7553b..ba8d1932e5b 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "rtlhooks-def.h" #include "emit-rtl.h" #include "ira.h" +#include "rtl-iter.h" #ifdef INSN_SCHEDULING #include "sel-sched-ir.h" @@ -798,58 +799,35 @@ substitute_reg_in_expr (expr_t expr, insn_t insn, bool undo) return false; } -/* Helper function for count_occurences_equiv. */ -static int -count_occurrences_1 (rtx *cur_rtx, void *arg) -{ - rtx_search_arg_p p = (rtx_search_arg_p) arg; - - if (REG_P (*cur_rtx) && REGNO (*cur_rtx) == REGNO (p->x)) - { - /* Bail out if mode is different or more than one register is used. */ - if (GET_MODE (*cur_rtx) != GET_MODE (p->x) - || (HARD_REGISTER_P (*cur_rtx) - && hard_regno_nregs[REGNO (*cur_rtx)][GET_MODE (*cur_rtx)] > 1)) - { - p->n = 0; - return 1; - } - - p->n++; - - /* Do not traverse subexprs. */ - return -1; - } - - if (GET_CODE (*cur_rtx) == SUBREG - && (!REG_P (SUBREG_REG (*cur_rtx)) - || REGNO (SUBREG_REG (*cur_rtx)) == REGNO (p->x))) - { - /* ??? Do not support substituting regs inside subregs. In that case, - simplify_subreg will be called by validate_replace_rtx, and - unsubstitution will fail later. */ - p->n = 0; - return 1; - } - - /* Continue search. */ - return 0; -} - /* Return the number of places WHAT appears within WHERE. Bail out when we found a reference occupying several hard registers. */ static int -count_occurrences_equiv (rtx what, rtx where) +count_occurrences_equiv (const_rtx what, const_rtx where) { - struct rtx_search_arg arg; - - gcc_assert (REG_P (what)); - arg.x = what; - arg.n = 0; - - for_each_rtx (&where, &count_occurrences_1, (void *) &arg); - - return arg.n; + int count = 0; + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, where, NONCONST) + { + const_rtx x = *iter; + if (REG_P (x) && REGNO (x) == REGNO (what)) + { + /* Bail out if mode is different or more than one register is + used. */ + if (GET_MODE (x) != GET_MODE (what) + || (HARD_REGISTER_P (x) + && hard_regno_nregs[REGNO (x)][GET_MODE (x)] > 1)) + return 0; + count += 1; + } + else if (GET_CODE (x) == SUBREG + && (!REG_P (SUBREG_REG (x)) + || REGNO (SUBREG_REG (x)) == REGNO (what))) + /* ??? Do not support substituting regs inside subregs. In that case, + simplify_subreg will be called by validate_replace_rtx, and + unsubstitution will fail later. */ + return 0; + } + return count; } /* Returns TRUE if WHAT is found in WHERE rtx tree. */ -- 2.11.4.GIT