This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR81362: Vector peeling
- From: Robin Dapp <rdapp at linux dot vnet dot ibm dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
- Date: Wed, 12 Jul 2017 17:11:48 +0200
- Subject: [PATCH] Fix PR81362: Vector peeling
- Authentication-results: sourceware.org; auth=none
The attached patch fixes PR81362.
npeel was erroneously overwritten by vect_peeling_hash_get_lowest_cost
although the corresponding dataref is not used afterwards. It should be
safe to get rid of the npeel parameter since we use the returned
peeling_info's npeel anyway. Also removed the body_cost_vec parameter
which is not used elsewhere.
Regards
Robin
--
gcc/ChangeLog:
2017-07-12 Robin Dapp <rdapp@linux.vnet.ibm.com>
* (vect_enhance_data_refs_alignment):
Remove body_cost_vec from _vect_peel_extended_info.
tree-vect-data-refs.c (vect_peeling_hash_get_lowest_cost):
Do not set body_cost_vec.
(vect_peeling_hash_choose_best_peeling): Remove body_cost_vec
and npeel.
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 5103ba1..0b8eee7 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -1161,7 +1161,6 @@ typedef struct _vect_peel_extended_info
struct _vect_peel_info peel_info;
unsigned int inside_cost;
unsigned int outside_cost;
- stmt_vector_for_cost body_cost_vec;
} *vect_peel_extended_info;
@@ -1309,6 +1308,8 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
vect_get_peeling_costs_all_drs (elem->dr, &inside_cost, &outside_cost,
&body_cost_vec, elem->npeel, false);
+ body_cost_vec.release ();
+
outside_cost += vect_get_known_peeling_cost
(loop_vinfo, elem->npeel, &dummy,
&LOOP_VINFO_SCALAR_ITERATION_COST (loop_vinfo),
@@ -1327,14 +1328,10 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
{
min->inside_cost = inside_cost;
min->outside_cost = outside_cost;
- min->body_cost_vec.release ();
- min->body_cost_vec = body_cost_vec;
min->peel_info.dr = elem->dr;
min->peel_info.npeel = elem->npeel;
min->peel_info.count = elem->count;
}
- else
- body_cost_vec.release ();
return 1;
}
@@ -1346,14 +1343,11 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
static struct _vect_peel_extended_info
vect_peeling_hash_choose_best_peeling (hash_table<peel_info_hasher> *peeling_htab,
- loop_vec_info loop_vinfo,
- unsigned int *npeel,
- stmt_vector_for_cost *body_cost_vec)
+ loop_vec_info loop_vinfo)
{
struct _vect_peel_extended_info res;
res.peel_info.dr = NULL;
- res.body_cost_vec = stmt_vector_for_cost ();
if (!unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo)))
{
@@ -1371,8 +1365,6 @@ vect_peeling_hash_choose_best_peeling (hash_table<peel_info_hasher> *peeling_hta
res.outside_cost = 0;
}
- *npeel = res.peel_info.npeel;
- *body_cost_vec = res.body_cost_vec;
return res;
}
@@ -1537,7 +1529,6 @@ 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 body_cost_vec = stmt_vector_for_cost ();
hash_table<peel_info_hasher> peeling_htab (1);
if (dump_enabled_p ())
@@ -1812,7 +1803,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
unless aligned. So we try to choose the best possible peeling from
the hash table. */
peel_for_known_alignment = vect_peeling_hash_choose_best_peeling
- (&peeling_htab, loop_vinfo, &npeel, &body_cost_vec);
+ (&peeling_htab, loop_vinfo);
}
/* Compare costs of peeling for known and unknown alignment. */
@@ -1838,7 +1829,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
{
/* Calculate the penalty for no peeling, i.e. leaving everything
unaligned.
- TODO: Adapt vect_get_peeling_costs_all_drs and use here. */
+ TODO: Adapt vect_get_peeling_costs_all_drs and use here.
+ TODO: Use nopeel_outside_cost or get rid of it? */
unsigned nopeel_inside_cost = 0;
unsigned nopeel_outside_cost = 0;
@@ -1920,10 +1912,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
if (!stat)
do_peeling = false;
else
- {
- body_cost_vec.release ();
- return stat;
- }
+ return stat;
}
/* Cost model #1 - honor --param vect-max-peeling-for-alignment. */
@@ -1999,19 +1988,16 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
dump_printf_loc (MSG_NOTE, vect_location,
"Peeling for alignment will be applied.\n");
}
+
/* The inside-loop cost will be accounted for in vectorizable_load
and vectorizable_store correctly with adjusted alignments.
Drop the body_cst_vec on the floor here. */
- body_cost_vec.release ();
-
stat = vect_verify_datarefs_alignment (loop_vinfo);
gcc_assert (stat);
return stat;
}
}
- body_cost_vec.release ();
-
/* (2) Versioning to force alignment. */
/* Try versioning if: