This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Make more use of GET_MODE_UNIT_SIZE
- From: Richard Sandiford <richard dot sandiford at linaro dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 23 Aug 2017 11:55:10 +0100
- Subject: Make more use of GET_MODE_UNIT_SIZE
- Authentication-results: sourceware.org; auth=none
This patch uses GET_MODE_UNIT_SIZE instead of GET_MODE_SIZE in
cases where, for compound modes, the mode of the scalar elements
is what matters. E.g. the choice between truncation and extension
is really based on the modes of the consistuent scalars rather
than the mode as a whole.
None of the existing code was wrong. The patch simply makes
things easier when converting to variable-sized modes.
Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure
that there were no differences in testsuite assembly output for one
target per CPU. OK to install?
Richard
2017-08-22 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* optabs.c (add_equal_note): Use GET_MODE_UNIT_SIZE.
(widened_mode): Likewise.
(expand_unop): Likewise.
* ree.c (transform_ifelse): Likewise.
(merge_def_and_ext): Likewise.
(combine_reaching_defs): Likewise.
* simplify-rtx.c (simplify_unary_operation_1): Likewise.
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c 2017-08-03 10:40:53.028490556 +0100
+++ gcc/optabs.c 2017-08-23 10:47:48.126586565 +0100
@@ -138,8 +138,8 @@ add_equal_note (rtx_insn *insns, rtx tar
if (GET_MODE (op0) != VOIDmode && GET_MODE (target) != GET_MODE (op0))
{
note = gen_rtx_fmt_e (code, GET_MODE (op0), copy_rtx (op0));
- if (GET_MODE_SIZE (GET_MODE (op0))
- > GET_MODE_SIZE (GET_MODE (target)))
+ if (GET_MODE_UNIT_SIZE (GET_MODE (op0))
+ > GET_MODE_UNIT_SIZE (GET_MODE (target)))
note = simplify_gen_unary (TRUNCATE, GET_MODE (target),
note, GET_MODE (op0));
else
@@ -173,12 +173,12 @@ widened_mode (machine_mode to_mode, rtx
if (m0 == VOIDmode && m1 == VOIDmode)
return to_mode;
- else if (m0 == VOIDmode || GET_MODE_SIZE (m0) < GET_MODE_SIZE (m1))
+ else if (m0 == VOIDmode || GET_MODE_UNIT_SIZE (m0) < GET_MODE_UNIT_SIZE (m1))
result = m1;
else
result = m0;
- if (GET_MODE_SIZE (result) > GET_MODE_SIZE (to_mode))
+ if (GET_MODE_UNIT_SIZE (result) > GET_MODE_UNIT_SIZE (to_mode))
return to_mode;
return result;
@@ -2982,9 +2982,9 @@ expand_unop (machine_mode mode, optab un
else
{
eq_value = gen_rtx_fmt_e (optab_to_code (unoptab), mode, op0);
- if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode))
+ if (GET_MODE_UNIT_SIZE (outmode) < GET_MODE_UNIT_SIZE (mode))
eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode);
- else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode))
+ else if (GET_MODE_UNIT_SIZE (outmode) > GET_MODE_UNIT_SIZE (mode))
eq_value = simplify_gen_unary (ZERO_EXTEND,
outmode, eq_value, mode);
}
Index: gcc/ree.c
===================================================================
--- gcc/ree.c 2017-08-23 10:44:17.185477350 +0100
+++ gcc/ree.c 2017-08-23 10:47:48.126586565 +0100
@@ -427,7 +427,8 @@ transform_ifelse (ext_cand *cand, rtx_in
srcreg2 = XEXP (SET_SRC (set_insn), 2);
/* If the conditional move already has the right or wider mode,
there is nothing to do. */
- if (GET_MODE_SIZE (GET_MODE (dstreg)) >= GET_MODE_SIZE (cand->mode))
+ if (GET_MODE_UNIT_SIZE (GET_MODE (dstreg))
+ >= GET_MODE_UNIT_SIZE (cand->mode))
return true;
map_srcreg = gen_rtx_REG (cand->mode, REGNO (srcreg));
@@ -717,8 +718,8 @@ merge_def_and_ext (ext_cand *cand, rtx_i
&& state->modified[INSN_UID (def_insn)].mode
== ext_src_mode)))
{
- if (GET_MODE_SIZE (GET_MODE (SET_DEST (*sub_rtx)))
- >= GET_MODE_SIZE (cand->mode))
+ if (GET_MODE_UNIT_SIZE (GET_MODE (SET_DEST (*sub_rtx)))
+ >= GET_MODE_UNIT_SIZE (cand->mode))
return true;
/* If def_insn is already scheduled to be deleted, don't attempt
to modify it. */
@@ -926,7 +927,8 @@ combine_reaching_defs (ext_cand *cand, c
|| (set = single_set (cand->insn)) == NULL_RTX)
return false;
mode = GET_MODE (SET_DEST (set));
- gcc_assert (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (cand->mode));
+ gcc_assert (GET_MODE_UNIT_SIZE (mode)
+ >= GET_MODE_UNIT_SIZE (cand->mode));
cand->mode = mode;
}
Index: gcc/simplify-rtx.c
===================================================================
--- gcc/simplify-rtx.c 2017-08-23 10:44:17.187477282 +0100
+++ gcc/simplify-rtx.c 2017-08-23 10:47:48.127582392 +0100
@@ -1266,10 +1266,9 @@ simplify_unary_operation_1 (enum rtx_cod
if ((GET_CODE (op) == FLOAT_TRUNCATE
&& flag_unsafe_math_optimizations)
|| GET_CODE (op) == FLOAT_EXTEND)
- return simplify_gen_unary (GET_MODE_SIZE (GET_MODE (XEXP (op,
- 0)))
- > GET_MODE_SIZE (mode)
- ? FLOAT_TRUNCATE : FLOAT_EXTEND,
+ return simplify_gen_unary (GET_MODE_UNIT_SIZE (GET_MODE (XEXP (op, 0)))
+ > GET_MODE_UNIT_SIZE (mode)
+ ? FLOAT_TRUNCATE : FLOAT_EXTEND,
mode,
XEXP (op, 0), mode);