This removes two calls to build_fold_indirect_ref which were only done to later call get_name on the result. Simply build a name in the first place instead of repeatedly doing so. It also adjusts dumping of what kind of object we vectorize (going from terribly wrong to most of the time wrong ...). The patch also commits one piece I had in my local tree for some time, state that the reason for not vectorizing is a non-empty latch block if we just checked that.
Bootstrap & regtest pending on x86_64-unknown-linux-gnu. Richard. 2013-01-03 Richard Biener <rguent...@suse.de> * tree-vect-loop.c (vect_analyze_loop_form): Clarify reason for not vectorizing. * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref): Do not build INDIRECT_REFs, call get_name once only. (vect_create_data_ref_ptr): Likewise. Dump base object kind based on DR_BASE_OBJECT, not DR_BASE_ADDRESS. Index: gcc/tree-vect-loop.c =================================================================== *** gcc/tree-vect-loop.c (revision 194844) --- gcc/tree-vect-loop.c (working copy) *************** vect_analyze_loop_form (struct loop *loo *** 1167,1177 **** before the loop if needed), where the loop header contains all the executable statements, and the latch is empty. */ if (!empty_block_p (loop->latch) ! || !gimple_seq_empty_p (phi_nodes (loop->latch))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, ! "not vectorized: unexpected loop form."); if (inner_loop_vinfo) destroy_loop_vec_info (inner_loop_vinfo, true); return NULL; --- 1167,1177 ---- before the loop if needed), where the loop header contains all the executable statements, and the latch is empty. */ if (!empty_block_p (loop->latch) ! || !gimple_seq_empty_p (phi_nodes (loop->latch))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, ! "not vectorized: latch block not empty."); if (inner_loop_vinfo) destroy_loop_vec_info (inner_loop_vinfo, true); return NULL; Index: gcc/tree-vect-data-refs.c =================================================================== *** gcc/tree-vect-data-refs.c (revision 194844) --- gcc/tree-vect-data-refs.c (working copy) *************** vect_create_addr_base_for_vector_ref (gi *** 3576,3582 **** stmt_vec_info stmt_info = vinfo_for_stmt (stmt); struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info); tree data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr)); ! tree base_name; tree data_ref_base_var; tree vec_stmt; tree addr_base, addr_expr; --- 3576,3582 ---- stmt_vec_info stmt_info = vinfo_for_stmt (stmt); struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info); tree data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr)); ! const char *base_name; tree data_ref_base_var; tree vec_stmt; tree addr_base, addr_expr; *************** vect_create_addr_base_for_vector_ref (gi *** 3601,3612 **** } if (loop_vinfo) ! base_name = build_fold_indirect_ref (data_ref_base); else { base_offset = ssize_int (0); init = ssize_int (0); ! base_name = build_fold_indirect_ref (unshare_expr (DR_REF (dr))); } data_ref_base_var = create_tmp_var (TREE_TYPE (data_ref_base), "batmp"); --- 3601,3612 ---- } if (loop_vinfo) ! base_name = get_name (data_ref_base); else { base_offset = ssize_int (0); init = ssize_int (0); ! base_name = get_name (DR_REF (dr)); } data_ref_base_var = create_tmp_var (TREE_TYPE (data_ref_base), "batmp"); *************** vect_create_addr_base_for_vector_ref (gi *** 3654,3660 **** vec_stmt = fold_convert (vect_ptr_type, addr_base); addr_expr = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var, ! get_name (base_name)); vec_stmt = force_gimple_operand (vec_stmt, &seq, false, addr_expr); gimple_seq_add_seq (new_stmt_list, seq); --- 3654,3660 ---- vec_stmt = fold_convert (vect_ptr_type, addr_base); addr_expr = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var, ! base_name); vec_stmt = force_gimple_operand (vec_stmt, &seq, false, addr_expr); gimple_seq_add_seq (new_stmt_list, seq); *************** vect_create_data_ref_ptr (gimple stmt, t *** 3729,3735 **** gimple_stmt_iterator *gsi, gimple *ptr_incr, bool only_init, bool *inv_p) { ! tree base_name; stmt_vec_info stmt_info = vinfo_for_stmt (stmt); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); struct loop *loop = NULL; --- 3729,3735 ---- gimple_stmt_iterator *gsi, gimple *ptr_incr, bool only_init, bool *inv_p) { ! const char *base_name; stmt_vec_info stmt_info = vinfo_for_stmt (stmt); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); struct loop *loop = NULL; *************** vect_create_data_ref_ptr (gimple stmt, t *** 3786,3808 **** /* Create an expression for the first address accessed by this load in LOOP. */ ! base_name = build_fold_indirect_ref (unshare_expr (DR_BASE_ADDRESS (dr))); if (dump_enabled_p ()) { ! tree data_ref_base = base_name; dump_printf_loc (MSG_NOTE, vect_location, "create %s-pointer variable to type: ", tree_code_name[(int) TREE_CODE (aggr_type)]); dump_generic_expr (MSG_NOTE, TDF_SLIM, aggr_type); ! if (TREE_CODE (data_ref_base) == VAR_DECL ! || TREE_CODE (data_ref_base) == ARRAY_REF) dump_printf (MSG_NOTE, " vectorizing an array ref: "); ! else if (TREE_CODE (data_ref_base) == COMPONENT_REF) dump_printf (MSG_NOTE, " vectorizing a record based array ref: "); ! else if (TREE_CODE (data_ref_base) == SSA_NAME) dump_printf (MSG_NOTE, " vectorizing a pointer ref: "); ! dump_generic_expr (MSG_NOTE, TDF_SLIM, base_name); } /* (1) Create the new aggregate-pointer variable. */ --- 3786,3807 ---- /* Create an expression for the first address accessed by this load in LOOP. */ ! base_name = get_name (DR_BASE_ADDRESS (dr)); if (dump_enabled_p ()) { ! tree dr_base_type = TREE_TYPE (DR_BASE_OBJECT (dr)); dump_printf_loc (MSG_NOTE, vect_location, "create %s-pointer variable to type: ", tree_code_name[(int) TREE_CODE (aggr_type)]); dump_generic_expr (MSG_NOTE, TDF_SLIM, aggr_type); ! if (TREE_CODE (dr_base_type) == ARRAY_TYPE) dump_printf (MSG_NOTE, " vectorizing an array ref: "); ! else if (TREE_CODE (dr_base_type) == RECORD_TYPE) dump_printf (MSG_NOTE, " vectorizing a record based array ref: "); ! else dump_printf (MSG_NOTE, " vectorizing a pointer ref: "); ! dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_BASE_OBJECT (dr)); } /* (1) Create the new aggregate-pointer variable. */ *************** vect_create_data_ref_ptr (gimple stmt, t *** 3813,3820 **** aggr_ptr_type = build_qualified_type (aggr_ptr_type, TYPE_QUALS (TREE_TYPE (TREE_OPERAND (base, 0)))); ! aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, ! get_name (base_name)); /* Vector and array types inherit the alias set of their component type by default so we need to use a ref-all pointer if the data --- 3812,3818 ---- aggr_ptr_type = build_qualified_type (aggr_ptr_type, TYPE_QUALS (TREE_TYPE (TREE_OPERAND (base, 0)))); ! aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, base_name); /* Vector and array types inherit the alias set of their component type by default so we need to use a ref-all pointer if the data *************** vect_create_data_ref_ptr (gimple stmt, t *** 3827,3833 **** = build_pointer_type_for_mode (aggr_type, TYPE_MODE (aggr_ptr_type), true); aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, ! get_name (base_name)); } /* Likewise for any of the data references in the stmt group. */ --- 3825,3831 ---- = build_pointer_type_for_mode (aggr_type, TYPE_MODE (aggr_ptr_type), true); aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, ! base_name); } /* Likewise for any of the data references in the stmt group. */ *************** vect_create_data_ref_ptr (gimple stmt, t *** 3845,3851 **** TYPE_MODE (aggr_ptr_type), true); aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, ! get_name (base_name)); break; } --- 3843,3849 ---- TYPE_MODE (aggr_ptr_type), true); aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, ! base_name); break; }