Fix PR45971: do not predicate condition phi nodes that are scev analyzable.

2010-11-10  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/45971
	* tree-if-conv.c (predicate_scalar_phi): Do not generate a COND_EXPR
	for phi nodes analyzable by scev.

	* gcc.dg/vect/O3-pr45971.c: New.

From-SVN: r166544
This commit is contained in:
Sebastian Pop 2010-11-10 16:06:47 +00:00 committed by Sebastian Pop
parent 59e0c6b70f
commit e639b20676
4 changed files with 31 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2010-11-10 Sebastian Pop <sebastian.pop@amd.com>
PR tree-optimization/45971
* tree-if-conv.c (predicate_scalar_phi): Do not generate a COND_EXPR
for phi nodes analyzable by scev.
2010-11-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44964

View file

@ -1,3 +1,8 @@
2010-11-10 Sebastian Pop <sebastian.pop@amd.com>
PR tree-optimization/45971
* gcc.dg/vect/O3-pr45971.c: New.
2010-11-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44964

View file

@ -0,0 +1,13 @@
/* { dg-do compile } */
/* { dg-require-effective-target vect_int } */
void
foo (int *x, int *y)
{
int i;
for (i = 0; i < 11; i++)
y[i] = (x[i] == 1) ? i + 1 : -(i + 1);
}
/* { dg-final { cleanup-tree-dump "vect" } } */

View file

@ -1224,7 +1224,7 @@ predicate_scalar_phi (gimple phi, tree cond,
{
gimple new_stmt;
basic_block bb;
tree rhs, res, arg;
tree rhs, res, arg, scev;
gcc_assert (gimple_code (phi) == GIMPLE_PHI
&& gimple_phi_num_args (phi) == 2);
@ -1236,8 +1236,12 @@ predicate_scalar_phi (gimple phi, tree cond,
bb = gimple_bb (phi);
arg = degenerate_phi_result (phi);
if (arg)
if ((arg = degenerate_phi_result (phi))
|| ((scev = analyze_scalar_evolution (gimple_bb (phi)->loop_father,
res))
&& !chrec_contains_undetermined (scev)
&& scev != res
&& (arg = gimple_phi_arg_def (phi, 0))))
rhs = arg;
else
{