diff options
author | Bill Schmidt <wschmidt@linux.ibm.com> | 2012-07-13 11:12:33 +0000 |
---|---|---|
committer | William Schmidt <wschmidt@gcc.gnu.org> | 2012-07-13 11:12:33 +0000 |
commit | c3e7ee4191ea60b02af9fff0ccc15d060961fde4 (patch) | |
tree | 53ffe7a4bc3844bca9190acaf1ea9eee86512108 /gcc/tree-vect-data-refs.c | |
parent | 44fabee4e252d91ea09daf23f7dd1cce3f63abea (diff) | |
download | gcc-c3e7ee4191ea60b02af9fff0ccc15d060961fde4.zip gcc-c3e7ee4191ea60b02af9fff0ccc15d060961fde4.tar.gz gcc-c3e7ee4191ea60b02af9fff0ccc15d060961fde4.tar.bz2 |
tm.texi: Regenerate.
2012-07-13 Bill Schmidt <wschmidt@linux.ibm.com>
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (TARGET_VECTORIZE_INIT_COST): New hook.
(TARGET_VECTORIZE_ADD_STMT_COST): Likewise.
(TARGET_VECTORIZE_FINISH_COST): Likewise.
(TARGET_VECTORIZE_DESTROY_COST_DATA): Likewise.
* targhooks.c (default_init_cost): New function.
(default_add_stmt_cost): Likewise.
(default_finish_cost): Likewise.
(default_destroy_cost_data): Likewise.
* targhooks.h (default_init_cost): New decl.
(default_add_stmt_cost): Likewise.
(default_finish_cost): Likewise.
(default_destroy_cost_data): Likewise.
* target.def (init_cost): New DEFHOOK.
(add_stmt_cost): Likewise.
(finish_cost): Likewise.
(destroy_cost_data): Likewise.
* target.h (struct _stmt_vec_info): New extern decl.
(stmt_vectype): Likewise.
(stmt_in_inner_loop_p): Likewise.
* tree-vectorizer.h (stmt_info_for_cost): New struct/typedef.
(stmt_vector_for_cost): New VEC/typedef.
(add_stmt_info_to_vec): New function.
(struct _slp_tree): Remove cost.inside_of_loop field.
(struct _slp_instance): Remove cost.inside_of_loop field; add
stmt_cost_vec field.
(SLP_INSTANCE_INSIDE_OF_LOOP_COST): Remove macro.
(SLP_INSTANCE_STMT_COST_VEC): New accessor macro.
(SLP_TREE_INSIDE_OF_LOOP_COST): Remove macro.
(struct _vect_peel_extended_info): Add stmt_cost_vec field.
(struct _loop_vec_info): Add target_cost_data field.
(LOOP_VINFO_TARGET_COST_DATA): New accessor macro.
(struct _bb_vec_info): Add target_cost_data field.
(BB_VINFO_TARGET_COST_DATA): New accessor macro.
(struct _stmt_vec_info): Remove cost.inside_of_loop field.
(STMT_VINFO_INSIDE_OF_LOOP_COST): Remove macro.
(stmt_vinfo_set_inside_of_loop_cost): Remove function.
(init_cost): New function.
(add_stmt_cost): Likewise.
(finish_cost): Likewise.
(destroy_cost_data): Likewise.
(vect_model_simple_cost): Change parameter list.
(vect_model_store_cost): Likewise.
(vect_model_load_cost): Likewise.
(record_stmt_cost): New extern decl.
(vect_get_load_cost): Change parameter list.
(vect_get_store_cost): Likewise.
* tree-vect-loop.c (new_loop_vec_info): Call init_cost.
(destroy_loop_vec_info): Call destroy_cost_data.
(vect_estimate_min_profitable_iters): Remove old calculation of
inside costs; call finish_cost instead.
(vect_model_reduction_cost): Call add_stmt_cost instead of old
inside-costs calculation.
(vect_model_induction_cost): Likewise.
* tree-vect-data-refs.c (vect_get_data_access_cost): Change to
return a stmt_vector_for_cost; modify calls to vect_get_load_cost
and vect_get_store_cost to obtain the value to return.
(vect_peeling_hash_get_lowest_cost): Obtain a stmt_cost_vec from
vect_get_data_access_cost and store it in the minimum peeling
structure.
(vect_peeling_hash_choose_best_peeling): Change the parameter list
to add a (stmt_vector_for_cost *) output parameter, and set its value.
(vect_enhance_data_refs_alignment): Ignore the new return value from
calls to vect_get_data_access_cost; obtain stmt_cost_vec from
vect_peeling_hash_choose_best_peeling and pass its contents to the
target cost model.
* tree-vect-stmts.c (stmt_vectype): New function.
(stmt_in_inner_loop_p): Likewise.
(record_stmt_cost): Likewise.
(vect_model_simple_cost): Add stmt_cost_vec parameter; call
record_stmt_cost instead of old calculation; don't call
stmt_vinfo_set_inside_of_loop_cost.
(vect_model_promotion_demotion_cost): Call add_stmt_cost instead of
old calculation; don't call stmt_vinfo_set_inside_of_loop_cost.
(vect_model_store_cost): Add stmt_cost_vec parameter; call
record_stmt_cost instead of old calculation; add stmt_cost_vec
parameter to vect_get_store_cost call; don't call
stmt_vinfo_set_inside_of_loop_cost.
(vect_get_store_cost): Add stmt_cost_vec parameter; call
record_stmt_cost instead of old calculation.
(vect_model_load_cost): Add stmt_cost_vec parameter; call
record_stmt_cost instead of old calculation; add stmt_cost_vec
parameter to vect_get_load_cost call; don't call
stmt_vinfo_set_inside_of_loop_cost.
(vect_get_load_cost): Add stmt_cost_vec parameter; call
record_stmt_cost instead of old calculation.
(vectorizable_call): Add NULL parameter to vect_model_simple_cost call.
(vectorizable_conversion): Likewise.
(vectorizable_assignment): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_store): Add NULL parameter to vect_model_store_cost call.
(vectorizable_load): Add NULL parameter to vect_model_load_cost call.
(new_stmt_vec_info): Don't set STMT_VINFO_INSIDE_OF_LOOP_COST.
* config/spu/spu.c (TARGET_VECTORIZE_INIT_COST): New macro def.
(TARGET_VECTORIZE_ADD_STMT_COST): Likewise.
(TARGET_VECTORIZE_FINISH_COST): Likewise.
(TARGET_VECTORIZE_DESTROY_COST_DATA): Likewise.
(spu_init_cost): New function.
(spu_add_stmt_cost): Likewise.
(spu_finish_cost): Likewise.
(spu_destroy_cost_data): Likewise.
* config/i386/i386.c (ix86_init_cost): New function.
(ix86_add_stmt_cost): Likewise.
(ix86_finish_cost): Likewise.
(ix86_destroy_cost_data): Likewise.
(TARGET_VECTORIZE_INIT_COST): New macro def.
(TARGET_VECTORIZE_ADD_STMT_COST): Likewise.
(TARGET_VECTORIZE_FINISH_COST): Likewise.
(TARGET_VECTORIZE_DESTROY_COST_DATA): Likewise.
* config/rs6000/rs6000.c (TARGET_VECTORIZE_INIT_COST): New macro def.
(TARGET_VECTORIZE_ADD_STMT_COST): Likewise.
(TARGET_VECTORIZE_FINISH_COST): Likewise.
(TARGET_VECTORIZE_DESTROY_COST_DATA): Likewise.
(rs6000_init_cost): New function.
(rs6000_add_stmt_cost): Likewise.
(rs6000_finish_cost): Likewise.
(rs6000_destroy_cost_data): Likewise.
* tree-vect-slp.c (vect_free_slp_instance): Free stmt_cost_vec.
(vect_create_new_slp_node): Don't set SLP_TREE_INSIDE_OF_LOOP_COST.
(vect_get_and_check_slp_defs): Add stmt_cost_vec parameter; add
stmt_cost_vec parameter to vect_model_store_cost and
vect_model_simple_cost calls.
(vect_build_slp_tree): Remove inside_cost parameter; add stmt_cost_vec
parameter; add stmt_cost_vec parameter to vect_get_and_check_slp_defs,
vect_model_load_cost, and recursive vect_build_slp_tree calls; prevent
calculating cost more than once for loads; remove inside_cost
parameter from recursive vect_build_slp_tree calls; call
record_stmt_cost instead of old calculation.
(vect_analyze_slp_instance): Allocate stmt_cost_vec and save it with
the instance; free it on premature exit; remove inside_cost parameter
from vect_build_slp_tree call; add stmt_cost_vec parameter to
vect_build_slp_tree call; don't set SLP_INSTANCE_INSIDE_OF_LOOP_COST.
(new_bb_vec_info): Call init_cost.
(destroy_bb_vec_info): Call destroy_cost_data.
(vect_bb_vectorization_profitable_p): Call add_stmt_cost for each
statement recorded with an SLP instance; call finish_cost instead of
the old calculation.
(vect_update_slp_costs_according_to_vf): Record statement costs from
SLP instances, multiplying by the appropriate number of copies; don't
update SLP_INSTANCE_INSIDE_OF_LOOP_COST.
From-SVN: r189460
Diffstat (limited to 'gcc/tree-vect-data-refs.c')
-rw-r--r-- | gcc/tree-vect-data-refs.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index f08c915..6d64c7b 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -1205,7 +1205,7 @@ vector_alignment_reachable_p (struct data_reference *dr) /* Calculate the cost of the memory access represented by DR. */ -static void +static stmt_vector_for_cost vect_get_data_access_cost (struct data_reference *dr, unsigned int *inside_cost, unsigned int *outside_cost) @@ -1216,15 +1216,19 @@ vect_get_data_access_cost (struct data_reference *dr, loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo); int ncopies = vf / nunits; + stmt_vector_for_cost stmt_cost_vec = VEC_alloc (stmt_info_for_cost, heap, 2); if (DR_IS_READ (dr)) - vect_get_load_cost (dr, ncopies, true, inside_cost, outside_cost); + vect_get_load_cost (dr, ncopies, true, inside_cost, + outside_cost, &stmt_cost_vec); else - vect_get_store_cost (dr, ncopies, inside_cost); + vect_get_store_cost (dr, ncopies, inside_cost, &stmt_cost_vec); if (vect_print_dump_info (REPORT_COST)) fprintf (vect_dump, "vect_get_data_access_cost: inside_cost = %d, " "outside_cost = %d.", *inside_cost, *outside_cost); + + return stmt_cost_vec; } @@ -1317,6 +1321,7 @@ vect_peeling_hash_get_lowest_cost (void **slot, void *data) loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo); struct data_reference *dr; + stmt_vector_for_cost stmt_cost_vec = NULL; FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr) { @@ -1330,7 +1335,8 @@ vect_peeling_hash_get_lowest_cost (void **slot, void *data) save_misalignment = DR_MISALIGNMENT (dr); vect_update_misalignment_for_peel (dr, elem->dr, elem->npeel); - vect_get_data_access_cost (dr, &inside_cost, &outside_cost); + stmt_cost_vec = vect_get_data_access_cost (dr, &inside_cost, + &outside_cost); SET_DR_MISALIGNMENT (dr, save_misalignment); } @@ -1342,6 +1348,7 @@ vect_peeling_hash_get_lowest_cost (void **slot, void *data) { min->inside_cost = inside_cost; min->outside_cost = outside_cost; + min->stmt_cost_vec = stmt_cost_vec; min->peel_info.dr = elem->dr; min->peel_info.npeel = elem->npeel; } @@ -1356,11 +1363,13 @@ vect_peeling_hash_get_lowest_cost (void **slot, void *data) static struct data_reference * vect_peeling_hash_choose_best_peeling (loop_vec_info loop_vinfo, - unsigned int *npeel) + unsigned int *npeel, + stmt_vector_for_cost *stmt_cost_vec) { struct _vect_peel_extended_info res; res.peel_info.dr = NULL; + res.stmt_cost_vec = NULL; if (flag_vect_cost_model) { @@ -1377,6 +1386,7 @@ vect_peeling_hash_choose_best_peeling (loop_vec_info loop_vinfo, } *npeel = res.peel_info.npeel; + *stmt_cost_vec = res.stmt_cost_vec; return res.peel_info.dr; } @@ -1493,6 +1503,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) unsigned possible_npeel_number = 1; tree vectype; unsigned int nelements, mis, same_align_drs_max = 0; + stmt_vector_for_cost stmt_cost_vec = NULL; if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "=== vect_enhance_data_refs_alignment ==="); @@ -1697,10 +1708,10 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) unsigned int load_inside_penalty = 0, load_outside_penalty = 0; unsigned int store_inside_penalty = 0, store_outside_penalty = 0; - vect_get_data_access_cost (dr0, &load_inside_cost, - &load_outside_cost); - vect_get_data_access_cost (first_store, &store_inside_cost, - &store_outside_cost); + (void) vect_get_data_access_cost (dr0, &load_inside_cost, + &load_outside_cost); + (void) vect_get_data_access_cost (first_store, &store_inside_cost, + &store_outside_cost); /* Calculate the penalty for leaving FIRST_STORE unaligned (by aligning the load DR0). */ @@ -1764,7 +1775,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) gcc_assert (!all_misalignments_unknown); /* Choose the best peeling from the hash table. */ - dr0 = vect_peeling_hash_choose_best_peeling (loop_vinfo, &npeel); + dr0 = vect_peeling_hash_choose_best_peeling (loop_vinfo, &npeel, + &stmt_cost_vec); if (!dr0 || !npeel) do_peeling = false; } @@ -1848,6 +1860,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) if (do_peeling) { + stmt_info_for_cost *si; + /* (1.2) Update the DR_MISALIGNMENT of each data reference DR_i. If the misalignment of DR_i is identical to that of dr0 then set DR_MISALIGNMENT (DR_i) to zero. If the misalignment of DR_i and @@ -1871,6 +1885,18 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "Peeling for alignment will be applied."); + /* We've delayed passing the inside-loop peeling costs to the + target cost model until we were sure peeling would happen. + Do so now. */ + if (stmt_cost_vec) + { + FOR_EACH_VEC_ELT (stmt_info_for_cost, stmt_cost_vec, i, si) + (void) add_stmt_cost (LOOP_VINFO_TARGET_COST_DATA (loop_vinfo), + si->count, si->kind, + vinfo_for_stmt (si->stmt), si->misalign); + VEC_free (stmt_info_for_cost, heap, stmt_cost_vec); + } + stat = vect_verify_datarefs_alignment (loop_vinfo, NULL); gcc_assert (stat); return stat; |