From 5dabe5a94ef83a96f437f9f3425caf0f5280f08d Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sun, 26 Oct 2014 10:40:15 +0000 Subject: [PATCH] sh-protos.h (shmedia_cleanup_truncate): Take an rtx as argument and return the number of changes. gcc/ * config/sh/sh-protos.h (shmedia_cleanup_truncate): Take an rtx as argument and return the number of changes. * config/sh/sh.c: Include rtl-iter.h. (shmedia_cleanup_truncate): Take an rtx as argument and iterate over all subrtxes. Return the number of changes made. * config/sh/sh.md: Update caller accordingly. From-SVN: r216701 --- gcc/ChangeLog | 9 +++++++++ gcc/config/sh/sh-protos.h | 2 +- gcc/config/sh/sh.c | 36 +++++++++++++++++++++--------------- gcc/config/sh/sh.md | 5 +---- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cf177bdc2b4..c33e0e5033e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2014-10-26 Richard Sandiford + + * config/sh/sh-protos.h (shmedia_cleanup_truncate): Take an + rtx as argument and return the number of changes. + * config/sh/sh.c: Include rtl-iter.h. + (shmedia_cleanup_truncate): Take an rtx as argument and iterate + over all subrtxes. Return the number of changes made. + * config/sh/sh.md: Update caller accordingly. + 2014-10-26 Richard Sandiford * config/m68k/m68k.c (m68k_tls_reference_p_1): Delete. diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 77c9ae4e342..a170c115374 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -215,7 +215,7 @@ extern void sh_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, extern rtx sh_dwarf_register_span (rtx); extern rtx replace_n_hard_rtx (rtx, rtx *, int , int); -extern int shmedia_cleanup_truncate (rtx *, void *); +extern int shmedia_cleanup_truncate (rtx); extern bool sh_contains_memref_p (rtx); extern bool sh_loads_bankedreg_p (rtx); diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 3daa375b957..2d1a9273a75 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -78,6 +78,7 @@ along with GCC; see the file COPYING3. If not see #include "pass_manager.h" #include "context.h" #include "builtins.h" +#include "rtl-iter.h" int code_for_indirect_jump_scratch = CODE_FOR_indirect_jump_scratch; @@ -12940,25 +12941,30 @@ sh_gen_truncate (enum machine_mode mode, rtx x, int need_sign_ext) return gen_rtx_fmt_e (code, mode, x); } -/* Called via for_each_rtx after reload, to clean up truncates of - registers that span multiple actual hard registers. */ +/* Look through X cleaning up truncates of registers that span multiple + actual hard registers. Return the number of changes made. */ int -shmedia_cleanup_truncate (rtx *p, void *n_changes) +shmedia_cleanup_truncate (rtx x) { - rtx x = *p, reg; - - if (GET_CODE (x) != TRUNCATE) - return 0; - reg = XEXP (x, 0); - if (GET_MODE_SIZE (GET_MODE (reg)) > 8 && REG_P (reg)) + int n_changes = 0; + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST) { - enum machine_mode reg_mode = GET_MODE (reg); - XEXP (x, 0) = simplify_subreg (DImode, reg, reg_mode, - subreg_lowpart_offset (DImode, reg_mode)); - *(int*) n_changes += 1; - return -1; + rtx x = *iter; + if (GET_CODE (x) == TRUNCATE) + { + rtx reg = XEXP (x, 0); + enum machine_mode reg_mode = GET_MODE (reg); + if (REG_P (reg) && GET_MODE_SIZE (reg_mode) > 8) + { + int offset = subreg_lowpart_offset (DImode, reg_mode); + XEXP (x, 0) = simplify_subreg (DImode, reg, reg_mode, offset); + n_changes += 1; + iter.skip_subrtxes (); + } + } } - return 0; + return n_changes; } /* Load and store depend on the highpart of the address. However, diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index b48be1092a3..e0c0940bf3c 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -15803,10 +15803,7 @@ label: "TARGET_SHMEDIA && reload_completed" [(set (match_dup 0) (match_dup 1))] { - int n_changes = 0; - - for_each_rtx (&operands[1], shmedia_cleanup_truncate, &n_changes); - if (!n_changes) + if (!shmedia_cleanup_truncate (operands[1])) FAIL; }) -- 2.30.2