From 546513775069e93d5f33f7aae5f1cb26c77ca2c9 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 30 Aug 2017 11:12:14 +0000 Subject: [28/77] Use is_a for miscellaneous types of test This patch adds is_a checks to various places that were explicitly or implicitly restricted to integers already, in cases where adding an explicit is_a is useful for later patches. In simplify_if_then_else, the: GET_MODE (XEXP (XEXP (t, 0), N)) expressions were equivalent to: GET_MODE (XEXP (t, 0)) due to the type of operation. 2017-08-30 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (sign_extend_short_imm): Add is_a checks. (try_combine): Likewise. (simplify_if_then_else): Likewise. * cse.c (cse_insn): Likewise. * dwarf2out.c (mem_loc_descriptor): Likewise. * emit-rtl.c (gen_lowpart_common): Likewise. * simplify-rtx.c (simplify_truncation): Likewise. (simplify_binary_operation_1): Likewise. (simplify_const_relational_operation): Likewise. (simplify_ternary_operation): Likewise. * tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Likewise. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r251480 --- gcc/emit-rtl.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gcc/emit-rtl.c') diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 3785eca..0391bea 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1430,9 +1430,11 @@ gen_lowpart_common (machine_mode mode, rtx x) if (SCALAR_FLOAT_MODE_P (mode) && msize > xsize) return 0; + scalar_int_mode int_mode, int_innermode, from_mode; if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND) - && (GET_MODE_CLASS (mode) == MODE_INT - || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)) + && is_a (mode, &int_mode) + && is_a (innermode, &int_innermode) + && is_a (GET_MODE (XEXP (x, 0)), &from_mode)) { /* If we are getting the low-order part of something that has been sign- or zero-extended, we can either just use the object being @@ -1442,12 +1444,12 @@ gen_lowpart_common (machine_mode mode, rtx x) This case is used mostly by combine and cse. */ - if (GET_MODE (XEXP (x, 0)) == mode) + if (from_mode == int_mode) return XEXP (x, 0); - else if (msize < GET_MODE_SIZE (GET_MODE (XEXP (x, 0)))) - return gen_lowpart_common (mode, XEXP (x, 0)); - else if (msize < xsize) - return gen_rtx_fmt_e (GET_CODE (x), mode, XEXP (x, 0)); + else if (GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (from_mode)) + return gen_lowpart_common (int_mode, XEXP (x, 0)); + else if (GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (int_innermode)) + return gen_rtx_fmt_e (GET_CODE (x), int_mode, XEXP (x, 0)); } else if (GET_CODE (x) == SUBREG || REG_P (x) || GET_CODE (x) == CONCAT || GET_CODE (x) == CONST_VECTOR -- cgit v1.1