diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:11:42 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:11:42 +0000 |
commit | 6b9c3decc38f6f852adf16951b9b1b043112cd1c (patch) | |
tree | e5f94df609e868850d97acfc272b72bc5ed4ed4b /gcc/expr.c | |
parent | 7c61657f68cc45bdbbfcfd762dbfd7021f3acb3f (diff) | |
download | gcc-6b9c3decc38f6f852adf16951b9b1b043112cd1c.zip gcc-6b9c3decc38f6f852adf16951b9b1b043112cd1c.tar.gz gcc-6b9c3decc38f6f852adf16951b9b1b043112cd1c.tar.bz2 |
[26/77] Use is_a <scalar_int_mode> in subreg/extract simplifications
This patch adds is_a <scalar_int_mode> checks to various places that
were optimising subregs or extractions in ways that only made sense
for scalar integers. Often the subreg transformations were looking
for extends, truncates or shifts and trying to remove the subreg, which
wouldn't be correct if the SUBREG_REG was a vector rather than a scalar.
The simplify_binary_operation_1 part also removes a redundant:
GET_MODE (opleft) == GET_MODE (XEXP (opright, 0))
since this must be true for:
(ior A (lshifrt B ...)) A == opleft, B == XEXP (opright, 0)
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* combine.c (find_split_point): Add is_a <scalar_int_mode> checks.
(make_compound_operation_int): Likewise.
(change_zero_ext): Likewise.
* expr.c (convert_move): Likewise.
(convert_modes): Likewise.
* fwprop.c (forward_propagate_subreg): Likewise.
* loop-iv.c (get_biv_step_1): Likewise.
* optabs.c (widen_operand): Likewise.
* postreload.c (move2add_valid_value_p): Likewise.
* recog.c (simplify_while_replacing): Likewise.
* simplify-rtx.c (simplify_unary_operation_1): Likewise.
(simplify_binary_operation_1): Likewise. Remove redundant
mode equality check.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251478
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -239,11 +239,14 @@ convert_move (rtx to, rtx from, int unsignedp) the required extension, strip it. We don't handle such SUBREGs as TO here. */ - if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) + scalar_int_mode to_int_mode; + if (GET_CODE (from) == SUBREG + && SUBREG_PROMOTED_VAR_P (from) + && is_a <scalar_int_mode> (to_mode, &to_int_mode) && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) - >= GET_MODE_PRECISION (to_mode)) + >= GET_MODE_PRECISION (to_int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) - from = gen_lowpart (to_mode, from), from_mode = to_mode; + from = gen_lowpart (to_int_mode, from), from_mode = to_int_mode; gcc_assert (GET_CODE (to) != SUBREG || !SUBREG_PROMOTED_VAR_P (to)); @@ -635,10 +638,12 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp) /* If FROM is a SUBREG that indicates that we have already done at least the required extension, strip it. */ - if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x) - && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode) + if (GET_CODE (x) == SUBREG + && SUBREG_PROMOTED_VAR_P (x) + && is_a <scalar_int_mode> (mode, &int_mode) + && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (int_mode) && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp)) - x = gen_lowpart (mode, SUBREG_REG (x)); + x = gen_lowpart (int_mode, SUBREG_REG (x)); if (GET_MODE (x) != VOIDmode) oldmode = GET_MODE (x); |