[parloops] Handle canonicalize_loop_ivs failure
2018-03-21 Tom de Vries <tom@codesourcery.com> PR tree-optimization/83126 * tree-parloops.c (num_phis): New function. (gen_parallel_loop): Detect and handle canonicalize_loop_ivs failure. * gcc.dg/graphite/pr83126.c: New test. From-SVN: r258713
This commit is contained in:
parent
f82ece6b59
commit
c75c35e0f5
4 changed files with 69 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2018-03-21 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
PR tree-optimization/83126
|
||||
* tree-parloops.c (num_phis): New function.
|
||||
(gen_parallel_loop): Detect and handle canonicalize_loop_ivs failure.
|
||||
|
||||
2018-03-21 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* doc/extend.texi (Deprecated Features): Update deprecared flags,
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2018-03-21 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
PR tree-optimization/83126
|
||||
* gcc.dg/graphite/pr83126.c: New test.
|
||||
|
||||
2018-03-21 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* g++.dg/ext/anon-struct6.C: Adjust.
|
||||
|
|
19
gcc/testsuite/gcc.dg/graphite/pr83126.c
Normal file
19
gcc/testsuite/gcc.dg/graphite/pr83126.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* { dg-additional-options "-w -ftree-parallelize-loops=2 -floop-parallelize-all -O1" } */
|
||||
|
||||
void
|
||||
ew (unsigned short int c9, int stuff)
|
||||
{
|
||||
int e1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
unsigned int *by = &e1;
|
||||
int *fd = &stuff;
|
||||
|
||||
*fd = c9;
|
||||
fd = *fd;
|
||||
if (*fd != 0)
|
||||
for (*by = 0; *by < 2; ++*by)
|
||||
c9 *= e1;
|
||||
}
|
||||
}
|
|
@ -2235,6 +2235,25 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
|
|||
calculate_dominance_info (CDI_DOMINATORS);
|
||||
}
|
||||
|
||||
/* Return number of phis in bb. If COUNT_VIRTUAL_P is false, don't count the
|
||||
virtual phi. */
|
||||
|
||||
static unsigned int
|
||||
num_phis (basic_block bb, bool count_virtual_p)
|
||||
{
|
||||
unsigned int nr_phis = 0;
|
||||
gphi_iterator gsi;
|
||||
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
||||
{
|
||||
if (!count_virtual_p && virtual_operand_p (PHI_RESULT (gsi.phi ())))
|
||||
continue;
|
||||
|
||||
nr_phis++;
|
||||
}
|
||||
|
||||
return nr_phis;
|
||||
}
|
||||
|
||||
/* Generates code to execute the iterations of LOOP in N_THREADS
|
||||
threads in parallel, which can be 0 if that number is to be determined
|
||||
later.
|
||||
|
@ -2370,6 +2389,26 @@ gen_parallel_loop (struct loop *loop,
|
|||
|
||||
/* Base all the induction variables in LOOP on a single control one. */
|
||||
canonicalize_loop_ivs (loop, &nit, true);
|
||||
if (num_phis (loop->header, false) != reduction_list->elements () + 1)
|
||||
{
|
||||
/* The call to canonicalize_loop_ivs above failed to "base all the
|
||||
induction variables in LOOP on a single control one". Do damage
|
||||
control. */
|
||||
basic_block preheader = loop_preheader_edge (loop)->src;
|
||||
basic_block cond_bb = single_pred (preheader);
|
||||
gcond *cond = as_a <gcond *> (gsi_stmt (gsi_last_bb (cond_bb)));
|
||||
gimple_cond_make_true (cond);
|
||||
update_stmt (cond);
|
||||
/* We've gotten rid of the duplicate loop created by loop_version, but
|
||||
we can't undo whatever canonicalize_loop_ivs has done.
|
||||
TODO: Fix this properly by ensuring that the call to
|
||||
canonicalize_loop_ivs succeeds. */
|
||||
if (dump_file
|
||||
&& (dump_flags & TDF_DETAILS))
|
||||
fprintf (dump_file, "canonicalize_loop_ivs failed for loop %d,"
|
||||
" aborting transformation\n", loop->num);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ensure that the exit condition is the first statement in the loop.
|
||||
The common case is that latch of the loop is empty (apart from the
|
||||
|
|
Loading…
Add table
Reference in a new issue