tree-vect-loop-manip.c (slpeel_add_loop_guard): New param and mark new edge's irreducible flag accordign to it.
* tree-vect-loop-manip.c (slpeel_add_loop_guard): New param and mark new edge's irreducible flag accordign to it. (vect_do_peeling): Check loop preheader edge's irreducible flag and pass it to function slpeel_add_loop_guard. gcc/testsuite * gcc.c-torture/compile/irreducible-loop.c: New. From-SVN: r246540
This commit is contained in:
parent
522818b971
commit
3e907b9056
@ -1,3 +1,10 @@
|
||||
2017-03-28 Bin Cheng <bin.cheng@arm.com>
|
||||
|
||||
* tree-vect-loop-manip.c (slpeel_add_loop_guard): New param and
|
||||
mark new edge's irreducible flag accordign to it.
|
||||
(vect_do_peeling): Check loop preheader edge's irreducible flag
|
||||
and pass it to function slpeel_add_loop_guard.
|
||||
|
||||
2017-03-28 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
PR tree-optimization/80218
|
||||
|
@ -1,6 +1,10 @@
|
||||
2017-03-28 Bin Cheng <bin.cheng@arm.com>
|
||||
|
||||
* gcc.c-torture/compile/irreducible-loop.c: New.
|
||||
|
||||
2017-03-28 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
PR tree-optimization/80218
|
||||
PR tree-optimization/80218
|
||||
* gcc.dg/pr80218.c: New test.
|
||||
|
||||
2017-03-28 Richard Biener <rguenther@suse.de>
|
||||
|
21
gcc/testsuite/gcc.c-torture/compile/irreducible-loop.c
Normal file
21
gcc/testsuite/gcc.c-torture/compile/irreducible-loop.c
Normal file
@ -0,0 +1,21 @@
|
||||
void foo (int n, double a, double *b, double *x)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if(n <= 0) return;
|
||||
if (a == 0.0e0) return;
|
||||
|
||||
if (a > 5.0)
|
||||
{
|
||||
i = 0;
|
||||
goto sec;
|
||||
}
|
||||
for (i = 0; i < 1024; i++)
|
||||
{
|
||||
double y = b[i];
|
||||
sec:
|
||||
b[i+1] = y + 5.0;
|
||||
for (j = 0; j < n; j++)
|
||||
x[j] = x[j] + a;
|
||||
}
|
||||
}
|
@ -534,12 +534,13 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
|
||||
/* Given the condition expression COND, put it as the last statement of
|
||||
GUARD_BB; set both edges' probability; set dominator of GUARD_TO to
|
||||
DOM_BB; return the skip edge. GUARD_TO is the target basic block to
|
||||
skip the loop. PROBABILITY is the skip edge's probability. */
|
||||
skip the loop. PROBABILITY is the skip edge's probability. Mark the
|
||||
new edge as irreducible if IRREDUCIBLE_P is true. */
|
||||
|
||||
static edge
|
||||
slpeel_add_loop_guard (basic_block guard_bb, tree cond,
|
||||
basic_block guard_to, basic_block dom_bb,
|
||||
int probability)
|
||||
int probability, bool irreducible_p)
|
||||
{
|
||||
gimple_stmt_iterator gsi;
|
||||
edge new_e, enter_e;
|
||||
@ -566,6 +567,9 @@ slpeel_add_loop_guard (basic_block guard_bb, tree cond,
|
||||
new_e->count = guard_bb->count;
|
||||
new_e->probability = probability;
|
||||
new_e->count = apply_probability (enter_e->count, probability);
|
||||
if (irreducible_p)
|
||||
new_e->flags |= EDGE_IRREDUCIBLE_LOOP;
|
||||
|
||||
enter_e->count -= new_e->count;
|
||||
enter_e->probability = inverse_probability (probability);
|
||||
set_immediate_dominator (CDI_DOMINATORS, guard_to, dom_bb);
|
||||
@ -1667,6 +1671,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
|
||||
|
||||
struct loop *prolog, *epilog = NULL, *loop = LOOP_VINFO_LOOP (loop_vinfo);
|
||||
struct loop *first_loop = loop;
|
||||
bool irred_flag = loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP;
|
||||
create_lcssa_for_virtual_phi (loop);
|
||||
update_ssa (TODO_update_ssa_only_virtuals);
|
||||
|
||||
@ -1748,7 +1753,8 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
|
||||
guard_to = split_edge (loop_preheader_edge (loop));
|
||||
guard_e = slpeel_add_loop_guard (guard_bb, guard_cond,
|
||||
guard_to, guard_bb,
|
||||
inverse_probability (prob_prolog));
|
||||
inverse_probability (prob_prolog),
|
||||
irred_flag);
|
||||
e = EDGE_PRED (guard_to, 0);
|
||||
e = (e != guard_e ? e : EDGE_PRED (guard_to, 1));
|
||||
slpeel_update_phi_nodes_for_guard1 (prolog, loop, guard_e, e);
|
||||
@ -1813,7 +1819,8 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
|
||||
guard_to = split_edge (loop_preheader_edge (epilog));
|
||||
guard_e = slpeel_add_loop_guard (guard_bb, guard_cond,
|
||||
guard_to, guard_bb,
|
||||
inverse_probability (prob_vector));
|
||||
inverse_probability (prob_vector),
|
||||
irred_flag);
|
||||
e = EDGE_PRED (guard_to, 0);
|
||||
e = (e != guard_e ? e : EDGE_PRED (guard_to, 1));
|
||||
slpeel_update_phi_nodes_for_guard1 (first_loop, epilog, guard_e, e);
|
||||
@ -1853,7 +1860,8 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
|
||||
guard_to = split_edge (single_exit (epilog));
|
||||
guard_e = slpeel_add_loop_guard (guard_bb, guard_cond, guard_to,
|
||||
skip_vector ? anchor : guard_bb,
|
||||
inverse_probability (prob_epilog));
|
||||
inverse_probability (prob_epilog),
|
||||
irred_flag);
|
||||
slpeel_update_phi_nodes_for_guard2 (loop, epilog, guard_e,
|
||||
single_exit (epilog));
|
||||
/* Only need to handle basic block before epilog loop if it's not
|
||||
|
Loading…
Reference in New Issue
Block a user