From 250a60f3879d2d508d0d08e9da1dfa1648e1a369 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 13 Oct 2017 09:53:00 +0000 Subject: [PATCH] Make more use of GET_MODE_UNIT_BITSIZE This patch is like the previous GET_MODE_UNIT_SIZE one, but for bit rather than byte sizes. 2017-10-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * cfgexpand.c (expand_debug_expr): Use GET_MODE_UNIT_BITSIZE. (expand_debug_source_expr): Likewise. * combine.c (combine_simplify_rtx): Likewise. * cse.c (fold_rtx): Likewise. * fwprop.c (canonicalize_address): Likewise. * targhooks.c (default_shift_truncation_mask): Likewise. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r253716 --- gcc/ChangeLog | 11 +++++++++++ gcc/cfgexpand.c | 12 ++++++++---- gcc/combine.c | 3 ++- gcc/cse.c | 7 ++++--- gcc/fwprop.c | 4 ++-- gcc/targhooks.c | 2 +- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8add08c4b23..0e29ae8a95d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2017-10-13 Richard Sandiford + Alan Hayward + David Sherwood + + * cfgexpand.c (expand_debug_expr): Use GET_MODE_UNIT_BITSIZE. + (expand_debug_source_expr): Likewise. + * combine.c (combine_simplify_rtx): Likewise. + * cse.c (fold_rtx): Likewise. + * fwprop.c (canonicalize_address): Likewise. + * targhooks.c (default_shift_truncation_mask): Likewise. + 2017-10-13 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index bd3312eb3ba..be93c5843e5 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -4326,9 +4326,11 @@ expand_debug_expr (tree exp) if (FLOAT_MODE_P (mode) && FLOAT_MODE_P (inner_mode)) { - if (GET_MODE_BITSIZE (mode) == GET_MODE_BITSIZE (inner_mode)) + if (GET_MODE_UNIT_BITSIZE (mode) + == GET_MODE_UNIT_BITSIZE (inner_mode)) op0 = simplify_gen_subreg (mode, op0, inner_mode, 0); - else if (GET_MODE_BITSIZE (mode) < GET_MODE_BITSIZE (inner_mode)) + else if (GET_MODE_UNIT_BITSIZE (mode) + < GET_MODE_UNIT_BITSIZE (inner_mode)) op0 = simplify_gen_unary (FLOAT_TRUNCATE, mode, op0, inner_mode); else op0 = simplify_gen_unary (FLOAT_EXTEND, mode, op0, inner_mode); @@ -5191,9 +5193,11 @@ expand_debug_source_expr (tree exp) if (FLOAT_MODE_P (mode) && FLOAT_MODE_P (inner_mode)) { - if (GET_MODE_BITSIZE (mode) == GET_MODE_BITSIZE (inner_mode)) + if (GET_MODE_UNIT_BITSIZE (mode) + == GET_MODE_UNIT_BITSIZE (inner_mode)) op0 = simplify_gen_subreg (mode, op0, inner_mode, 0); - else if (GET_MODE_BITSIZE (mode) < GET_MODE_BITSIZE (inner_mode)) + else if (GET_MODE_UNIT_BITSIZE (mode) + < GET_MODE_UNIT_BITSIZE (inner_mode)) op0 = simplify_gen_unary (FLOAT_TRUNCATE, mode, op0, inner_mode); else op0 = simplify_gen_unary (FLOAT_EXTEND, mode, op0, inner_mode); diff --git a/gcc/combine.c b/gcc/combine.c index 4d2f79b3d71..aa246e67bab 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6304,7 +6304,8 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, SUBST (XEXP (x, 1), force_to_mode (XEXP (x, 1), GET_MODE (XEXP (x, 1)), (HOST_WIDE_INT_1U - << exact_log2 (GET_MODE_BITSIZE (GET_MODE (x)))) + << exact_log2 (GET_MODE_UNIT_BITSIZE + (GET_MODE (x)))) - 1, 0)); break; diff --git a/gcc/cse.c b/gcc/cse.c index 717aaf8779d..25653ac77bb 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -3612,7 +3612,7 @@ fold_rtx (rtx x, rtx_insn *insn) { if (SHIFT_COUNT_TRUNCATED) canon_const_arg1 = GEN_INT (INTVAL (const_arg1) - & (GET_MODE_BITSIZE (mode) + & (GET_MODE_UNIT_BITSIZE (mode) - 1)); else break; @@ -3661,7 +3661,8 @@ fold_rtx (rtx x, rtx_insn *insn) { if (SHIFT_COUNT_TRUNCATED) inner_const = GEN_INT (INTVAL (inner_const) - & (GET_MODE_BITSIZE (mode) - 1)); + & (GET_MODE_UNIT_BITSIZE (mode) + - 1)); else break; } @@ -3691,7 +3692,7 @@ fold_rtx (rtx x, rtx_insn *insn) /* As an exception, we can turn an ASHIFTRT of this form into a shift of the number of bits - 1. */ if (code == ASHIFTRT) - new_const = GEN_INT (GET_MODE_BITSIZE (mode) - 1); + new_const = GEN_INT (GET_MODE_UNIT_BITSIZE (mode) - 1); else if (!side_effects_p (XEXP (y, 0))) return CONST0_RTX (mode); else diff --git a/gcc/fwprop.c b/gcc/fwprop.c index ca997490cf1..b77006b4801 100644 --- a/gcc/fwprop.c +++ b/gcc/fwprop.c @@ -357,8 +357,8 @@ canonicalize_address (rtx x) { case ASHIFT: if (CONST_INT_P (XEXP (x, 1)) - && INTVAL (XEXP (x, 1)) < GET_MODE_BITSIZE (GET_MODE (x)) - && INTVAL (XEXP (x, 1)) >= 0) + && INTVAL (XEXP (x, 1)) < GET_MODE_UNIT_BITSIZE (GET_MODE (x)) + && INTVAL (XEXP (x, 1)) >= 0) { HOST_WIDE_INT shift = INTVAL (XEXP (x, 1)); PUT_CODE (x, MULT); diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 8dbf8a14970..ae2595113f8 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -245,7 +245,7 @@ default_unwind_word_mode (void) unsigned HOST_WIDE_INT default_shift_truncation_mask (machine_mode mode) { - return SHIFT_COUNT_TRUNCATED ? GET_MODE_BITSIZE (mode) - 1 : 0; + return SHIFT_COUNT_TRUNCATED ? GET_MODE_UNIT_BITSIZE (mode) - 1 : 0; } /* The default implementation of TARGET_MIN_DIVISIONS_FOR_RECIP_MUL. */ -- 2.30.2