https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70434
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c (revision 234517) +++ gcc/c-family/c-common.c (working copy) @@ -12456,46 +12456,11 @@ convert_vector_to_pointer_for_subscript || 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); + *vecp = build1 (VIEW_CONVERT_EXPR, + build_array_type_nelts (TREE_TYPE (type), + TYPE_VECTOR_SUBPARTS (type)), + *vecp); + c_common_mark_addressable_vec (*vecp); } return ret; } but note we fail to re-write v into SSA and thus generated code is worse (but the same for both cases). .optimized has bar4 (int x, v4si v) { int _2; int _3; int _4; int _7; <bb 2>: _2 = VIEW_CONVERT_EXPR<int[4]>(v)[0]; _3 = VIEW_CONVERT_EXPR<int[4]>(v)[1]; _4 = _2 ^ _3; VIEW_CONVERT_EXPR<int[4]>(v)[0] = _4; _7 = VIEW_CONVERT_EXPR<int[4]>(v)[x_6(D)]; return _7; where you can see we miss foldings for V_C_E<array>(x)[CST] into BIT_FIELD_REFs. It at least avoids taking the address of 'v'. With a BIT_FIELD_INSERT we could re-write 'v' into SSA.