From 3d2b003490a4e40eaa659907bbd23f932f82be5e Mon Sep 17 00:00:00 2001 From: rsandifo Date: Wed, 30 Aug 2017 11:19:29 +0000 Subject: [PATCH] [65/77] Add a SCALAR_TYPE_MODE macro This patch adds a SCALAR_TYPE_MODE macro, along the same lines as SCALAR_INT_TYPE_MODE and SCALAR_FLOAT_TYPE_MODE. It also adds two instances of as_a to c_common_type, when converting an unsigned fixed-point SCALAR_TYPE_MODE to the equivalent signed mode. 2017-08-30 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (SCALAR_TYPE_MODE): New macro. * expr.c (expand_expr_addr_expr_1): Use it. (expand_expr_real_2): Likewise. * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise. (fold_convert_const_fixed_from_int): Likewise. (fold_convert_const_fixed_from_real): Likewise. (native_encode_fixed): Likewise (native_encode_complex): Likewise (native_encode_vector): Likewise. (native_interpret_fixed): Likewise. (native_interpret_real): Likewise. (native_interpret_complex): Likewise. (native_interpret_vector): Likewise. * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise. (simd_clone_adjust_argument_types): Likewise. (simd_clone_init_simd_arrays): Likewise. (simd_clone_adjust): Likewise. * stor-layout.c (layout_type): Likewise. * tree.c (build_minus_one_cst): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. (check_bool_pattern): Likewise. (adjust_bool_pattern): Likewise. (search_type_for_mask_1): Likewise. * tree-vect-slp.c (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. (vectorizable_load): Likewise. (vectorizable_store): Likewise. * ubsan.c (ubsan_encode_value): Likewise. * varasm.c (output_constant): Likewise. gcc/c-family/ * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE. * c-common.c (c_build_vec_perm_expr): Likewise. gcc/c/ * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE. (c_common_type): Likewise. Use as_a when setting m1 and m2 to the signed equivalent of a fixed-point SCALAR_TYPE_MODE. gcc/cp/ * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251516 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 40 ++++++++++++++++++++++++++++++++++++++++ gcc/c-family/ChangeLog | 7 +++++++ gcc/c-family/c-common.c | 4 ++-- gcc/c-family/c-lex.c | 2 +- gcc/c/ChangeLog | 9 +++++++++ gcc/c/c-typeck.c | 18 +++++++++++------- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 4 ++-- gcc/expr.c | 4 ++-- gcc/fold-const.c | 24 ++++++++++++------------ gcc/omp-simd-clone.c | 12 ++++++------ gcc/stor-layout.c | 14 +++++++++----- gcc/tree-cfg.c | 2 +- gcc/tree-inline.c | 2 +- gcc/tree-ssa-math-opts.c | 7 ++++--- gcc/tree-vect-loop.c | 6 ++++-- gcc/tree-vect-patterns.c | 16 ++++++++-------- gcc/tree-vect-slp.c | 2 +- gcc/tree-vect-stmts.c | 19 +++++++++---------- gcc/tree.c | 5 +++-- gcc/tree.h | 2 ++ gcc/ubsan.c | 9 ++++----- gcc/varasm.c | 2 +- 23 files changed, 145 insertions(+), 71 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d9895f36e9e..f67f411491d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,46 @@ Alan Hayward David Sherwood + * tree.h (SCALAR_TYPE_MODE): New macro. + * expr.c (expand_expr_addr_expr_1): Use it. + (expand_expr_real_2): Likewise. + * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise. + (fold_convert_const_fixed_from_int): Likewise. + (fold_convert_const_fixed_from_real): Likewise. + (native_encode_fixed): Likewise + (native_encode_complex): Likewise + (native_encode_vector): Likewise. + (native_interpret_fixed): Likewise. + (native_interpret_real): Likewise. + (native_interpret_complex): Likewise. + (native_interpret_vector): Likewise. + * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise. + (simd_clone_adjust_argument_types): Likewise. + (simd_clone_init_simd_arrays): Likewise. + (simd_clone_adjust): Likewise. + * stor-layout.c (layout_type): Likewise. + * tree.c (build_minus_one_cst): Likewise. + * tree-cfg.c (verify_gimple_assign_ternary): Likewise. + * tree-inline.c (estimate_move_cost): Likewise. + * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise. + * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. + (vectorizable_reduction): Likewise. + * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise. + (vect_recog_mixed_size_cond_pattern): Likewise. + (check_bool_pattern): Likewise. + (adjust_bool_pattern): Likewise. + (search_type_for_mask_1): Likewise. + * tree-vect-slp.c (vect_schedule_slp_instance): Likewise. + * tree-vect-stmts.c (vectorizable_conversion): Likewise. + (vectorizable_load): Likewise. + (vectorizable_store): Likewise. + * ubsan.c (ubsan_encode_value): Likewise. + * varasm.c (output_constant): Likewise. + +2017-08-30 Richard Sandiford + Alan Hayward + David Sherwood + * coretypes.h (scalar_mode): New class. * machmode.h (scalar_mode): Likewise. (scalar_mode::includes_p): New function. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index fe3fd5829ed..a715b57f5e9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -2,6 +2,13 @@ Alan Hayward David Sherwood + * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE. + * c-common.c (c_build_vec_perm_expr): Likewise. + +2017-08-30 Richard Sandiford + Alan Hayward + David Sherwood + * c-attribs.c (handle_mode_attribute): Check for a scalar_int_mode before calling targetm.addr_space.valid_pointer_mode. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 9754a66c4b9..18b2d1acc4f 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1031,8 +1031,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask, return error_mark_node; } - if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0)))) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (mask))))) + if (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (v0)))) + != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (mask))))) { if (complain) error_at (loc, "__builtin_shuffle argument vector(s) inner type " diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index a614b266baf..8342800303a 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -1110,7 +1110,7 @@ interpret_fixed (const cpp_token *token, unsigned int flags) memcpy (copy, token->val.str.text, copylen); copy[copylen] = '\0'; - fixed_from_string (&fixed, copy, TYPE_MODE (type)); + fixed_from_string (&fixed, copy, SCALAR_TYPE_MODE (type)); /* Create a node with determined type and value. */ value = build_fixed (type, fixed); diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 0cf7bd26167..dc269d5dea4 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2017-08-30 Richard Sandiford + Alan Hayward + David Sherwood + + * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE. + (c_common_type): Likewise. Use as_a when setting + m1 and m2 to the signed equivalent of a fixed-point + SCALAR_TYPE_MODE. + 2017-08-24 David Malcolm * c-tree.h (c_expr::get_location) Use EXPR_HAS_LOCATION rather diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index d7ca14801b9..135dd9d665c 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -812,11 +812,11 @@ c_common_type (tree t1, tree t2) if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE) { unsigned int unsignedp = 0, satp = 0; - machine_mode m1, m2; + scalar_mode m1, m2; unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit; - m1 = TYPE_MODE (t1); - m2 = TYPE_MODE (t2); + m1 = SCALAR_TYPE_MODE (t1); + m2 = SCALAR_TYPE_MODE (t2); /* If one input type is saturating, the result type is saturating. */ if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2)) @@ -848,7 +848,8 @@ c_common_type (tree t1, tree t2) mclass = MODE_ACCUM; else gcc_unreachable (); - m1 = mode_for_size (GET_MODE_PRECISION (m1), mclass, 0); + m1 = as_a + (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0)); } if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2)) { @@ -859,7 +860,8 @@ c_common_type (tree t1, tree t2) mclass = MODE_ACCUM; else gcc_unreachable (); - m2 = mode_for_size (GET_MODE_PRECISION (m2), mclass, 0); + m2 = as_a + (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0)); } } @@ -11414,7 +11416,8 @@ build_binary_op (location_t location, enum tree_code code, /* Always construct signed integer vector type. */ intt = c_common_type_for_size (GET_MODE_BITSIZE - (TYPE_MODE (TREE_TYPE (type0))), 0); + (SCALAR_TYPE_MODE + (TREE_TYPE (type0))), 0); result_type = build_opaque_vector_type (intt, TYPE_VECTOR_SUBPARTS (type0)); converted = 1; @@ -11573,7 +11576,8 @@ build_binary_op (location_t location, enum tree_code code, /* Always construct signed integer vector type. */ intt = c_common_type_for_size (GET_MODE_BITSIZE - (TYPE_MODE (TREE_TYPE (type0))), 0); + (SCALAR_TYPE_MODE + (TREE_TYPE (type0))), 0); result_type = build_opaque_vector_type (intt, TYPE_VECTOR_SUBPARTS (type0)); converted = 1; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 42375e9c902..69267c0ec35 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -2,6 +2,12 @@ Alan Hayward David Sherwood + * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE. + +2017-08-30 Richard Sandiford + Alan Hayward + David Sherwood + * cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE. 2017-08-30 Richard Sandiford diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 63667f34e6a..171c2dfb57c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4952,8 +4952,8 @@ cp_build_binary_op (location_t location, } /* Always construct signed integer vector type. */ - intt = c_common_type_for_size (GET_MODE_BITSIZE - (TYPE_MODE (TREE_TYPE (type0))), 0); + intt = c_common_type_for_size + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (type0))), 0); if (!intt) { if (complain & tf_error) diff --git a/gcc/expr.c b/gcc/expr.c index 71a81ef1f30..c586e7ce506 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7766,7 +7766,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, scalar_int_mode tmode, The expression is therefore always offset by the size of the scalar type. */ offset = 0; - bitpos = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp))); + bitpos = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (exp))); inner = TREE_OPERAND (exp, 0); break; @@ -9443,7 +9443,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, { tree sel_type = TREE_TYPE (treeop2); machine_mode vmode - = mode_for_vector (TYPE_MODE (TREE_TYPE (sel_type)), + = mode_for_vector (SCALAR_TYPE_MODE (TREE_TYPE (sel_type)), TYPE_VECTOR_SUBPARTS (sel_type)); gcc_assert (GET_MODE_CLASS (vmode) == MODE_VECTOR_INT); op2 = simplify_subreg (vmode, op2, TYPE_MODE (sel_type), 0); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e61195d9763..c921f1cf927 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2050,8 +2050,8 @@ fold_convert_const_fixed_from_fixed (tree type, const_tree arg1) tree t; bool overflow_p; - overflow_p = fixed_convert (&value, TYPE_MODE (type), &TREE_FIXED_CST (arg1), - TYPE_SATURATING (type)); + overflow_p = fixed_convert (&value, SCALAR_TYPE_MODE (type), + &TREE_FIXED_CST (arg1), TYPE_SATURATING (type)); t = build_fixed (type, value); /* Propagate overflow flags. */ @@ -2079,7 +2079,7 @@ fold_convert_const_fixed_from_int (tree type, const_tree arg1) else di.high = TREE_INT_CST_ELT (arg1, 1); - overflow_p = fixed_convert_from_int (&value, TYPE_MODE (type), di, + overflow_p = fixed_convert_from_int (&value, SCALAR_TYPE_MODE (type), di, TYPE_UNSIGNED (TREE_TYPE (arg1)), TYPE_SATURATING (type)); t = build_fixed (type, value); @@ -2100,7 +2100,7 @@ fold_convert_const_fixed_from_real (tree type, const_tree arg1) tree t; bool overflow_p; - overflow_p = fixed_convert_from_real (&value, TYPE_MODE (type), + overflow_p = fixed_convert_from_real (&value, SCALAR_TYPE_MODE (type), &TREE_REAL_CST (arg1), TYPE_SATURATING (type)); t = build_fixed (type, value); @@ -7027,7 +7027,7 @@ static int native_encode_fixed (const_tree expr, unsigned char *ptr, int len, int off) { tree type = TREE_TYPE (expr); - machine_mode mode = TYPE_MODE (type); + scalar_mode mode = SCALAR_TYPE_MODE (type); int total_bytes = GET_MODE_SIZE (mode); FIXED_VALUE_TYPE value; tree i_value, i_type; @@ -7129,7 +7129,7 @@ native_encode_complex (const_tree expr, unsigned char *ptr, int len, int off) return 0; part = TREE_IMAGPART (expr); if (off != -1) - off = MAX (0, off - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (part)))); + off = MAX (0, off - GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE (part)))); isize = native_encode_expr (part, ptr+rsize, len-rsize, off); if (off == -1 && isize != rsize) @@ -7153,7 +7153,7 @@ native_encode_vector (const_tree expr, unsigned char *ptr, int len, int off) offset = 0; count = VECTOR_CST_NELTS (expr); itype = TREE_TYPE (TREE_TYPE (expr)); - size = GET_MODE_SIZE (TYPE_MODE (itype)); + size = GET_MODE_SIZE (SCALAR_TYPE_MODE (itype)); for (i = 0; i < count; i++) { if (off >= size) @@ -7281,7 +7281,8 @@ native_interpret_int (tree type, const unsigned char *ptr, int len) static tree native_interpret_fixed (tree type, const unsigned char *ptr, int len) { - int total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); + scalar_mode mode = SCALAR_TYPE_MODE (type); + int total_bytes = GET_MODE_SIZE (mode); double_int result; FIXED_VALUE_TYPE fixed_value; @@ -7290,7 +7291,7 @@ native_interpret_fixed (tree type, const unsigned char *ptr, int len) return NULL_TREE; result = double_int::from_buffer (ptr, total_bytes); - fixed_value = fixed_from_double_int (result, TYPE_MODE (type)); + fixed_value = fixed_from_double_int (result, mode); return build_fixed (type, fixed_value); } @@ -7312,7 +7313,6 @@ native_interpret_real (tree type, const unsigned char *ptr, int len) REAL_VALUE_TYPE r; long tmp[6]; - total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); if (total_bytes > len || total_bytes > 24) return NULL_TREE; int words = (32 / BITS_PER_UNIT) / UNITS_PER_WORD; @@ -7367,7 +7367,7 @@ native_interpret_complex (tree type, const unsigned char *ptr, int len) int size; etype = TREE_TYPE (type); - size = GET_MODE_SIZE (TYPE_MODE (etype)); + size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype)); if (size * 2 > len) return NULL_TREE; rpart = native_interpret_expr (etype, ptr, size); @@ -7392,7 +7392,7 @@ native_interpret_vector (tree type, const unsigned char *ptr, int len) tree *elements; etype = TREE_TYPE (type); - size = GET_MODE_SIZE (TYPE_MODE (etype)); + size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype)); count = TYPE_VECTOR_SUBPARTS (type); if (size * count > len) return NULL_TREE; diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 0a3a386f33d..18eecd4335b 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -496,7 +496,7 @@ simd_clone_adjust_return_type (struct cgraph_node *node) veclen = node->simdclone->vecsize_int; else veclen = node->simdclone->vecsize_float; - veclen /= GET_MODE_BITSIZE (TYPE_MODE (t)); + veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (t)); if (veclen > node->simdclone->simdlen) veclen = node->simdclone->simdlen; if (POINTER_TYPE_P (t)) @@ -606,7 +606,7 @@ simd_clone_adjust_argument_types (struct cgraph_node *node) veclen = sc->vecsize_int; else veclen = sc->vecsize_float; - veclen /= GET_MODE_BITSIZE (TYPE_MODE (parm_type)); + veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (parm_type)); if (veclen > sc->simdlen) veclen = sc->simdlen; adj.arg_prefix = "simd"; @@ -650,7 +650,7 @@ simd_clone_adjust_argument_types (struct cgraph_node *node) veclen = sc->vecsize_int; else veclen = sc->vecsize_float; - veclen /= GET_MODE_BITSIZE (TYPE_MODE (base_type)); + veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type)); if (veclen > sc->simdlen) veclen = sc->simdlen; if (sc->mask_mode != VOIDmode) @@ -792,8 +792,8 @@ simd_clone_init_simd_arrays (struct cgraph_node *node, arg = DECL_CHAIN (arg); j++; } - elemsize - = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (arg)))); + tree elemtype = TREE_TYPE (TREE_TYPE (arg)); + elemsize = GET_MODE_SIZE (SCALAR_TYPE_MODE (elemtype)); tree t = build2 (MEM_REF, TREE_TYPE (arg), ptr, build_int_cst (ptype, k * elemsize)); t = build2 (MODIFY_EXPR, TREE_TYPE (t), t, arg); @@ -1226,7 +1226,7 @@ simd_clone_adjust (struct cgraph_node *node) mask_array, iter1, NULL, NULL); g = gimple_build_assign (mask, aref); gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING); - int bitsize = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (aref))); + int bitsize = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (aref))); if (!INTEGRAL_TYPE_P (TREE_TYPE (aref))) { aref = build1 (VIEW_CONVERT_EXPR, diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 012602d2298..d6c1bb6e1f5 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2219,10 +2219,13 @@ layout_type (tree type) } case FIXED_POINT_TYPE: - /* TYPE_MODE (type) has been set already. */ - TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); - break; + { + /* TYPE_MODE (type) has been set already. */ + scalar_mode mode = SCALAR_TYPE_MODE (type); + TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); + TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); + break; + } case COMPLEX_TYPE: TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type)); @@ -2243,7 +2246,8 @@ layout_type (tree type) /* Find an appropriate mode for the vector type. */ if (TYPE_MODE (type) == VOIDmode) SET_TYPE_MODE (type, - mode_for_vector (TYPE_MODE (innertype), nunits)); + mode_for_vector (SCALAR_TYPE_MODE (innertype), + nunits)); TYPE_SATURATING (type) = TYPE_SATURATING (TREE_TYPE (type)); TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type)); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index c156b81b186..b7593068ea9 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -4192,7 +4192,7 @@ verify_gimple_assign_ternary (gassign *stmt) if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE || GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs3_type))) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1_type)))) + != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (rhs1_type)))) { error ("invalid mask type in vector permute expression"); debug_generic_expr (lhs_type); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 1652f2f916a..cce5dc7b7bc 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3879,7 +3879,7 @@ estimate_move_cost (tree type, bool ARG_UNUSED (speed_p)) if (TREE_CODE (type) == VECTOR_TYPE) { - machine_mode inner = TYPE_MODE (TREE_TYPE (type)); + scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (type)); machine_mode simd = targetm.vectorize.preferred_simd_mode (inner); int simd_mode_size = GET_MODE_SIZE (simd); diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 86a1559050d..818290cf47c 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -3350,7 +3350,8 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt, optab this_optab; enum tree_code wmult_code; enum insn_code handler; - machine_mode to_mode, from_mode, actual_mode; + scalar_mode to_mode, from_mode; + machine_mode actual_mode; location_t loc = gimple_location (stmt); int actual_precision; bool from_unsigned1, from_unsigned2; @@ -3446,8 +3447,8 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt, else return false; - to_mode = TYPE_MODE (type); - from_mode = TYPE_MODE (type1); + to_mode = SCALAR_TYPE_MODE (type); + from_mode = SCALAR_TYPE_MODE (type1); from_unsigned1 = TYPE_UNSIGNED (type1); from_unsigned2 = TYPE_UNSIGNED (type2); optype = type1; diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 59e41f69d9f..5a1d9ff7a5a 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -4809,7 +4809,8 @@ vect_create_epilog_for_reduction (vec vect_defs, gimple *stmt, (index_vec_type); /* Get an unsigned integer version of the type of the data vector. */ - int scalar_precision = GET_MODE_PRECISION (TYPE_MODE (scalar_type)); + int scalar_precision + = GET_MODE_PRECISION (SCALAR_TYPE_MODE (scalar_type)); tree scalar_type_unsigned = make_unsigned_type (scalar_precision); tree vectype_unsigned = build_vector_type (scalar_type_unsigned, TYPE_VECTOR_SUBPARTS (vectype)); @@ -6211,7 +6212,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, } else { - int scalar_precision = GET_MODE_PRECISION (TYPE_MODE (scalar_type)); + int scalar_precision + = GET_MODE_PRECISION (SCALAR_TYPE_MODE (scalar_type)); cr_index_scalar_type = make_unsigned_type (scalar_precision); cr_index_vector_type = build_vector_type (cr_index_scalar_type, TYPE_VECTOR_SUBPARTS (vectype_out)); diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 6bc4f7ed7ad..4fee7a8f60c 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -939,8 +939,8 @@ vect_recog_widen_mult_pattern (vec *stmts, tree itype = type; if (TYPE_PRECISION (type) > TYPE_PRECISION (half_type0) * 2) itype = build_nonstandard_integer_type - (GET_MODE_BITSIZE (TYPE_MODE (half_type0)) * 2, - TYPE_UNSIGNED (type)); + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (half_type0)) * 2, + TYPE_UNSIGNED (type)); /* Pattern detected. */ if (dump_enabled_p ()) @@ -3083,7 +3083,7 @@ vect_recog_mixed_size_cond_pattern (vec *stmts, tree *type_in, TYPE_UNSIGNED (type)); if (itype == NULL_TREE - || GET_MODE_BITSIZE (TYPE_MODE (itype)) != cmp_mode_size) + || GET_MODE_BITSIZE (SCALAR_TYPE_MODE (itype)) != cmp_mode_size) return NULL; vecitype = get_vectype_for_scalar_type (itype); @@ -3200,7 +3200,7 @@ check_bool_pattern (tree var, vec_info *vinfo, hash_set &stmts) if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE) { - machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); + scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1)); tree itype = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1); vecitype = get_vectype_for_scalar_type (itype); @@ -3322,7 +3322,7 @@ adjust_bool_pattern (tree var, tree out_type, irhs1 = *defs.get (rhs1); tree def_rhs1 = gimple_assign_rhs1 (def_stmt); if (TYPE_PRECISION (TREE_TYPE (irhs1)) - == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (def_rhs1)))) + == GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (def_rhs1)))) { rhs_code = def_rhs_code; rhs1 = def_rhs1; @@ -3341,7 +3341,7 @@ adjust_bool_pattern (tree var, tree out_type, irhs2 = *defs.get (rhs2); tree def_rhs1 = gimple_assign_rhs1 (def_stmt); if (TYPE_PRECISION (TREE_TYPE (irhs2)) - == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (def_rhs1)))) + == GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (def_rhs1)))) { rhs_code = def_rhs_code; rhs1 = def_rhs1; @@ -3391,7 +3391,7 @@ adjust_bool_pattern (tree var, tree out_type, || (TYPE_PRECISION (TREE_TYPE (rhs1)) != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1))))) { - machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); + scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1)); itype = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1); } @@ -3544,7 +3544,7 @@ search_type_for_mask_1 (tree var, vec_info *vinfo, if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE || !TYPE_UNSIGNED (TREE_TYPE (rhs1))) { - machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); + scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1)); res = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1); } else diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 08746b49f82..38738930be3 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3754,7 +3754,7 @@ vect_schedule_slp_instance (slp_tree node, slp_instance instance, v1 = SLP_TREE_VEC_STMTS (node).copy (); SLP_TREE_VEC_STMTS (node).truncate (0); tree meltype = build_nonstandard_integer_type - (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vectype))), 1); + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (vectype))), 1); tree mvectype = get_same_sized_vectype (meltype, vectype); unsigned k = 0, l; for (j = 0; j < v0.length (); ++j) diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 96606bd4970..e17918a44b1 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -4070,7 +4070,6 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, vec interm_types = vNULL; tree last_oprnd, intermediate_type, cvt_type = NULL_TREE; int op_type; - machine_mode rhs_mode; unsigned short fltsz; /* Is STMT a vectorizable conversion? */ @@ -4213,6 +4212,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, needs to be generated. */ gcc_assert (ncopies >= 1); + machine_mode lhs_mode = SCALAR_TYPE_MODE (lhs_type); + machine_mode rhs_mode = SCALAR_TYPE_MODE (rhs_type); + /* Supportable by target? */ switch (modifier) { @@ -4241,12 +4243,11 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, } if (code != FLOAT_EXPR - || (GET_MODE_SIZE (TYPE_MODE (lhs_type)) - <= GET_MODE_SIZE (TYPE_MODE (rhs_type)))) + || GET_MODE_SIZE (lhs_mode) <= GET_MODE_SIZE (rhs_mode)) goto unsupported; - fltsz = GET_MODE_SIZE (TYPE_MODE (lhs_type)); - FOR_EACH_2XWIDER_MODE (rhs_mode, TYPE_MODE (rhs_type)) + fltsz = GET_MODE_SIZE (lhs_mode); + FOR_EACH_2XWIDER_MODE (rhs_mode, rhs_mode) { if (GET_MODE_SIZE (rhs_mode) > fltsz) break; @@ -4298,11 +4299,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, break; if (code != FIX_TRUNC_EXPR - || (GET_MODE_SIZE (TYPE_MODE (lhs_type)) - >= GET_MODE_SIZE (TYPE_MODE (rhs_type)))) + || GET_MODE_SIZE (lhs_mode) >= GET_MODE_SIZE (rhs_mode)) goto unsupported; - rhs_mode = TYPE_MODE (rhs_type); cvt_type = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), 0); cvt_type = get_same_sized_vectype (cvt_type, vectype_in); @@ -6026,7 +6025,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, /* First check if vec_extract optab doesn't support extraction of vector elts directly. */ - machine_mode elmode = TYPE_MODE (elem_type); + scalar_mode elmode = SCALAR_TYPE_MODE (elem_type); machine_mode vmode = mode_for_vector (elmode, group_size); if (! VECTOR_MODE_P (vmode) || (convert_optab_handler (vec_extract_optab, @@ -7064,7 +7063,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, { /* First check if vec_init optab supports construction from vector elts directly. */ - machine_mode elmode = TYPE_MODE (TREE_TYPE (vectype)); + scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vectype)); machine_mode vmode = mode_for_vector (elmode, group_size); if (VECTOR_MODE_P (vmode) && (convert_optab_handler (vec_init_optab, diff --git a/gcc/tree.c b/gcc/tree.c index 92a32c82a00..0420808e2f9 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2132,8 +2132,9 @@ build_minus_one_cst (tree type) case FIXED_POINT_TYPE: /* We can only generate 1 for accum types. */ gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); - return build_fixed (type, fixed_from_double_int (double_int_minus_one, - TYPE_MODE (type))); + return build_fixed (type, + fixed_from_double_int (double_int_minus_one, + SCALAR_TYPE_MODE (type))); case VECTOR_TYPE: { diff --git a/gcc/tree.h b/gcc/tree.h index 8347669b414..19dd8073c55 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1849,6 +1849,8 @@ extern void protected_set_expr_location (tree, location_t); #define TYPE_MODE(NODE) \ (VECTOR_TYPE_P (TYPE_CHECK (NODE)) \ ? vector_type_mode (NODE) : (NODE)->type_common.mode) +#define SCALAR_TYPE_MODE(NODE) \ + (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_INT_TYPE_MODE(NODE) \ (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_FLOAT_TYPE_MODE(NODE) \ diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 9b2083ff42b..1030168e6b7 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -124,7 +124,8 @@ tree ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase) { tree type = TREE_TYPE (t); - const unsigned int bitsize = GET_MODE_BITSIZE (TYPE_MODE (type)); + scalar_mode mode = SCALAR_TYPE_MODE (type); + const unsigned int bitsize = GET_MODE_BITSIZE (mode); if (bitsize <= POINTER_SIZE) switch (TREE_CODE (type)) { @@ -161,10 +162,8 @@ ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase) } if (phase == UBSAN_ENCODE_VALUE_RTL) { - rtx mem - = assign_stack_temp_for_type (TYPE_MODE (type), - GET_MODE_SIZE (TYPE_MODE (type)), - type); + rtx mem = assign_stack_temp_for_type (mode, GET_MODE_SIZE (mode), + type); SET_DECL_RTL (var, mem); expand_assignment (var, t, false); return build_fold_addr_expr (var); diff --git a/gcc/varasm.c b/gcc/varasm.c index f10f26eb0f1..adf99fb717a 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4885,7 +4885,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align, break; case VECTOR_CST: { - machine_mode inner = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp))); + scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (exp))); unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (inner)); int elt_size = GET_MODE_SIZE (inner); output_constant (VECTOR_CST_ELT (exp, 0), elt_size, align, -- 2.11.4.GIT