diff options
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r-- | gcc/c-family/c-common.c | 60 |
1 files changed, 14 insertions, 46 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 146e805..4568cf6 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -12496,66 +12496,34 @@ build_userdef_literal (tree suffix_id, tree value, return literal; } -/* For vector[index], convert the vector to a - pointer of the underlying type. Return true if the resulting - ARRAY_REF should not be an lvalue. */ +/* For vector[index], convert the vector to an array of the underlying type. + Return true if the resulting ARRAY_REF should not be an lvalue. */ bool -convert_vector_to_pointer_for_subscript (location_t loc, - tree *vecp, tree index) +convert_vector_to_array_for_subscript (location_t loc, + tree *vecp, tree index) { bool ret = false; if (VECTOR_TYPE_P (TREE_TYPE (*vecp))) { tree type = TREE_TYPE (*vecp); - tree type1; ret = !lvalue_p (*vecp); + if (TREE_CODE (index) == INTEGER_CST) if (!tree_fits_uhwi_p (index) || tree_to_uhwi (index) >= TYPE_VECTOR_SUBPARTS (type)) warning_at (loc, OPT_Warray_bounds, "index value is out of bound"); - if (ret) - { - tree tmp = create_tmp_var_raw (type); - DECL_SOURCE_LOCATION (tmp) = loc; - *vecp = c_save_expr (*vecp); - if (TREE_CODE (*vecp) == C_MAYBE_CONST_EXPR) - { - bool non_const = C_MAYBE_CONST_EXPR_NON_CONST (*vecp); - *vecp = C_MAYBE_CONST_EXPR_EXPR (*vecp); - *vecp - = c_wrap_maybe_const (build4 (TARGET_EXPR, type, tmp, - *vecp, NULL_TREE, NULL_TREE), - non_const); - } - else - *vecp = build4 (TARGET_EXPR, type, tmp, *vecp, - NULL_TREE, NULL_TREE); - SET_EXPR_LOCATION (*vecp, loc); - c_common_mark_addressable_vec (tmp); - } - else - c_common_mark_addressable_vec (*vecp); - type = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type)); - type1 = build_pointer_type (TREE_TYPE (*vecp)); - bool ref_all = TYPE_REF_CAN_ALIAS_ALL (type1); - if (!ref_all - && !DECL_P (*vecp)) - { - /* If the original vector isn't declared may_alias and it - isn't a bare vector look if the subscripting would - alias the vector we subscript, and if not, force ref-all. */ - alias_set_type vecset = get_alias_set (*vecp); - alias_set_type sset = get_alias_set (type); - if (!alias_sets_must_conflict_p (sset, vecset) - && !alias_set_subset_of (sset, vecset)) - ref_all = true; - } - type = build_pointer_type_for_mode (type, ptr_mode, ref_all); - *vecp = build1 (ADDR_EXPR, type1, *vecp); - *vecp = convert (type, *vecp); + /* We are building an ARRAY_REF so mark the vector as addressable + to not run into the gimplifiers premature setting of DECL_GIMPLE_REG_P + for function parameters. */ + c_common_mark_addressable_vec (*vecp); + + *vecp = build1 (VIEW_CONVERT_EXPR, + build_array_type_nelts (TREE_TYPE (type), + TYPE_VECTOR_SUBPARTS (type)), + *vecp); } return ret; } |