Commit 5e4e37bf by Richard Sandiford Committed by Richard Sandiford

[50/77] Add helper routines for SUBREG_PROMOTED_VAR_P subregs

When subregs contain promoted values, as indicated by
SUBREG_PROMOTED_VAR_P, both the unpromoted (outer) and
promoted (inner) values are known to be scalar integers.
This patch adds helper routines that get the modes as
scalar_int_modes.

2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* rtl.h (subreg_unpromoted_mode, subreg_promoted_mode): New functions.
	* expr.c (convert_move): Use them.
	(convert_modes): Likewise.
	(store_expr_with_bounds): Likewise.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r251502
parent 401581b6
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* rtl.h (subreg_unpromoted_mode, subreg_promoted_mode): New functions.
* expr.c (convert_move): Use them.
(convert_modes): Likewise.
(store_expr_with_bounds): Likewise.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* rtl.h (rtl_hooks::reg_nonzero_bits): Add a scalar_int_mode * rtl.h (rtl_hooks::reg_nonzero_bits): Add a scalar_int_mode
parameter for the mode of "x". Remove the "known_x", "known_mode" parameter for the mode of "x". Remove the "known_x", "known_mode"
and "known_ret" arguments. Change the type of the mode argument and "known_ret" arguments. Change the type of the mode argument
......
...@@ -243,7 +243,7 @@ convert_move (rtx to, rtx from, int unsignedp) ...@@ -243,7 +243,7 @@ convert_move (rtx to, rtx from, int unsignedp)
if (GET_CODE (from) == SUBREG if (GET_CODE (from) == SUBREG
&& SUBREG_PROMOTED_VAR_P (from) && SUBREG_PROMOTED_VAR_P (from)
&& is_a <scalar_int_mode> (to_mode, &to_int_mode) && is_a <scalar_int_mode> (to_mode, &to_int_mode)
&& (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) && (GET_MODE_PRECISION (subreg_promoted_mode (from))
>= GET_MODE_PRECISION (to_int_mode)) >= GET_MODE_PRECISION (to_int_mode))
&& SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp))
from = gen_lowpart (to_int_mode, from), from_mode = to_int_mode; from = gen_lowpart (to_int_mode, from), from_mode = to_int_mode;
...@@ -641,7 +641,8 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp) ...@@ -641,7 +641,8 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp)
if (GET_CODE (x) == SUBREG if (GET_CODE (x) == SUBREG
&& SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_VAR_P (x)
&& is_a <scalar_int_mode> (mode, &int_mode) && is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (int_mode) && (GET_MODE_PRECISION (subreg_promoted_mode (x))
>= GET_MODE_PRECISION (int_mode))
&& SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp)) && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp))
x = gen_lowpart (int_mode, SUBREG_REG (x)); x = gen_lowpart (int_mode, SUBREG_REG (x));
...@@ -5422,6 +5423,8 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, ...@@ -5422,6 +5423,8 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p,
expression. */ expression. */
{ {
rtx inner_target = 0; rtx inner_target = 0;
scalar_int_mode outer_mode = subreg_unpromoted_mode (target);
scalar_int_mode inner_mode = subreg_promoted_mode (target);
/* We can do the conversion inside EXP, which will often result /* We can do the conversion inside EXP, which will often result
in some optimizations. Do the conversion in two steps: first in some optimizations. Do the conversion in two steps: first
...@@ -5431,7 +5434,7 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, ...@@ -5431,7 +5434,7 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p,
converting modes. */ converting modes. */
if (INTEGRAL_TYPE_P (TREE_TYPE (exp)) if (INTEGRAL_TYPE_P (TREE_TYPE (exp))
&& TREE_TYPE (TREE_TYPE (exp)) == 0 && TREE_TYPE (TREE_TYPE (exp)) == 0
&& GET_MODE_PRECISION (GET_MODE (target)) && GET_MODE_PRECISION (outer_mode)
== TYPE_PRECISION (TREE_TYPE (exp))) == TYPE_PRECISION (TREE_TYPE (exp)))
{ {
if (!SUBREG_CHECK_PROMOTED_SIGN (target, if (!SUBREG_CHECK_PROMOTED_SIGN (target,
...@@ -5451,8 +5454,7 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, ...@@ -5451,8 +5454,7 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p,
} }
exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode
(GET_MODE (SUBREG_REG (target)), (inner_mode, SUBREG_PROMOTED_SIGN (target)),
SUBREG_PROMOTED_SIGN (target)),
exp); exp);
inner_target = SUBREG_REG (target); inner_target = SUBREG_REG (target);
...@@ -5478,10 +5480,9 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, ...@@ -5478,10 +5480,9 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p,
sure that we properly convert it. */ sure that we properly convert it. */
if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode) if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
{ {
temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)), temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)),
temp, SUBREG_PROMOTED_SIGN (target)); temp, SUBREG_PROMOTED_SIGN (target));
temp = convert_modes (GET_MODE (SUBREG_REG (target)), temp = convert_modes (inner_mode, outer_mode, temp,
GET_MODE (target), temp,
SUBREG_PROMOTED_SIGN (target)); SUBREG_PROMOTED_SIGN (target));
} }
......
...@@ -2764,6 +2764,24 @@ unwrap_const_vec_duplicate (T x) ...@@ -2764,6 +2764,24 @@ unwrap_const_vec_duplicate (T x)
return x; return x;
} }
/* Return the unpromoted (outer) mode of SUBREG_PROMOTED_VAR_P subreg X. */
inline scalar_int_mode
subreg_unpromoted_mode (rtx x)
{
gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x));
return as_a <scalar_int_mode> (GET_MODE (x));
}
/* Return the promoted (inner) mode of SUBREG_PROMOTED_VAR_P subreg X. */
inline scalar_int_mode
subreg_promoted_mode (rtx x)
{
gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x));
return as_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)));
}
/* In emit-rtl.c */ /* In emit-rtl.c */
extern rtvec gen_rtvec_v (int, rtx *); extern rtvec gen_rtvec_v (int, rtx *);
extern rtvec gen_rtvec_v (int, rtx_insn **); extern rtvec gen_rtvec_v (int, rtx_insn **);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment