From b3ad445f853ab7ca0da6216ff1bebfd6f90425f5 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 1 Nov 2017 12:52:50 +0000 Subject: [PATCH] Add narrower_subreg_mode helper function This patch adds a narrowing equivalent of wider_subreg_mode. At present there is only one user. 2017-11-01 Richard Sandiford Alan Hayward David Sherwood gcc/ * rtl.h (narrower_subreg_mode): New function. * ira-color.c (update_costs_from_allocno): Use it. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r254304 --- gcc/ChangeLog | 7 +++++++ gcc/ira-color.c | 17 ++++++++--------- gcc/rtl.h | 10 ++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3843db8..bdd6b73 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,13 @@ Alan Hayward David Sherwood + * rtl.h (narrower_subreg_mode): New function. + * ira-color.c (update_costs_from_allocno): Use it. + +2017-11-01 Richard Sandiford + Alan Hayward + David Sherwood + * optabs-query.h (convert_optab_p): New function, split out from... (convert_optab_handler): ...here. (widening_optab_handler): Delete. diff --git a/gcc/ira-color.c b/gcc/ira-color.c index 240eb48..0148058 100644 --- a/gcc/ira-color.c +++ b/gcc/ira-color.c @@ -1367,15 +1367,14 @@ update_costs_from_allocno (ira_allocno_t allocno, int hard_regno, || ALLOCNO_ASSIGNED_P (another_allocno)) continue; - if (GET_MODE_SIZE (ALLOCNO_MODE (cp->second)) < GET_MODE_SIZE (mode)) - /* If we have different modes use the smallest one. It is - a sub-register move. It is hard to predict what LRA - will reload (the pseudo or its sub-register) but LRA - will try to minimize the data movement. Also for some - register classes bigger modes might be invalid, - e.g. DImode for AREG on x86. For such cases the - register move cost will be maximal. */ - mode = ALLOCNO_MODE (cp->second); + /* If we have different modes use the smallest one. It is + a sub-register move. It is hard to predict what LRA + will reload (the pseudo or its sub-register) but LRA + will try to minimize the data movement. Also for some + register classes bigger modes might be invalid, + e.g. DImode for AREG on x86. For such cases the + register move cost will be maximal. */ + mode = narrower_subreg_mode (mode, ALLOCNO_MODE (cp->second)); cost = (cp->second == allocno ? ira_register_move_cost[mode][rclass][aclass] diff --git a/gcc/rtl.h b/gcc/rtl.h index 53635a2..8de5a1c 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2955,6 +2955,16 @@ subreg_lowpart_offset (machine_mode outermode, machine_mode innermode) } /* Given that a subreg has outer mode OUTERMODE and inner mode INNERMODE, + return the smaller of the two modes if they are different sizes, + otherwise return the outer mode. */ + +inline machine_mode +narrower_subreg_mode (machine_mode outermode, machine_mode innermode) +{ + return paradoxical_subreg_p (outermode, innermode) ? innermode : outermode; +} + +/* Given that a subreg has outer mode OUTERMODE and inner mode INNERMODE, return the mode that is big enough to hold both the outer and inner values. Prefer the outer mode in the event of a tie. */ -- 2.7.4