Commit 3fd7fe21 by Richard Biener Committed by Richard Biener

re PR tree-optimization/81053 (ICE on valid code at -O3 on x86_64-linux-gnu: in…

re PR tree-optimization/81053 (ICE on valid code at -O3 on x86_64-linux-gnu: in as_a, at is-a.h:192)

2017-06-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81053
	* tree-vect-loop.c (vect_is_simple_reduction): Handle PHI
	with backedge value not defined in loop.  Simplify def stmt
	compute.

	* gcc.dg/torture/pr81053.c: New testcase.

From-SVN: r249113
parent d1609a23
2017-06-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/81053
* tree-vect-loop.c (vect_is_simple_reduction): Handle PHI
with backedge value not defined in loop. Simplify def stmt
compute.
2017-06-11 Tom de Vries <tom@codesourcery.com> 2017-06-11 Tom de Vries <tom@codesourcery.com>
PR target/79939 PR target/79939
......
2017-06-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/81053
* gcc.dg/torture/pr81053.c: New testcase.
2017-06-10 Thomas Koenig <tkoenig@gcc.gnu.org> 2017-06-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/80988 PR fortran/80988
......
/* { dg-do compile } */
int a, b[2], c, d;
void fn1 ()
{
for (; d < 2; d++)
{
b[d] = a;
a = c;
}
}
...@@ -2790,15 +2790,17 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi, ...@@ -2790,15 +2790,17 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
} }
def_stmt = SSA_NAME_DEF_STMT (loop_arg); def_stmt = SSA_NAME_DEF_STMT (loop_arg);
if (gimple_nop_p (def_stmt)) if (is_gimple_assign (def_stmt))
{ {
if (dump_enabled_p ()) name = gimple_assign_lhs (def_stmt);
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, phi_def = false;
"reduction: no def_stmt\n");
return NULL;
} }
else if (gimple_code (def_stmt) == GIMPLE_PHI)
if (!is_gimple_assign (def_stmt) && gimple_code (def_stmt) != GIMPLE_PHI) {
name = PHI_RESULT (def_stmt);
phi_def = true;
}
else
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
{ {
...@@ -2809,37 +2811,27 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi, ...@@ -2809,37 +2811,27 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
return NULL; return NULL;
} }
if (is_gimple_assign (def_stmt))
{
name = gimple_assign_lhs (def_stmt);
phi_def = false;
}
else
{
name = PHI_RESULT (def_stmt);
phi_def = true;
}
nloop_uses = 0; nloop_uses = 0;
auto_vec<gphi *, 3> lcphis; auto_vec<gphi *, 3> lcphis;
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) if (flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)))
{ FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
gimple *use_stmt = USE_STMT (use_p); {
if (is_gimple_debug (use_stmt)) gimple *use_stmt = USE_STMT (use_p);
continue; if (is_gimple_debug (use_stmt))
if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) continue;
nloop_uses++; if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
else nloop_uses++;
/* We can have more than one loop-closed PHI. */ else
lcphis.safe_push (as_a <gphi *> (use_stmt)); /* We can have more than one loop-closed PHI. */
if (nloop_uses > 1) lcphis.safe_push (as_a <gphi *> (use_stmt));
{ if (nloop_uses > 1)
if (dump_enabled_p ()) {
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, if (dump_enabled_p ())
"reduction used in loop.\n"); dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
return NULL; "reduction used in loop.\n");
} return NULL;
} }
}
/* If DEF_STMT is a phi node itself, we expect it to have a single argument /* If DEF_STMT is a phi node itself, we expect it to have a single argument
defined in the inner loop. */ defined in the inner loop. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment