re PR middle-end/55481 (-O2 generates a wrong-code infinite loop in C++Benchmark's simple_types_constant_folding int8 xor test)
2012-12-12 Zdenek Dvorak <ook@ucw.cz> PR tree-optimization/55481 * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Fall back to general rewriting if we cannot leave an original biv definition alone. * gcc.dg/torture/pr55481.c: New testcase. From-SVN: r194444
This commit is contained in:
parent
85619b6fc1
commit
d06a01bf68
|
@ -1,3 +1,10 @@
|
||||||
|
2012-12-12 Zdenek Dvorak <ook@ucw.cz>
|
||||||
|
|
||||||
|
PR tree-optimization/55481
|
||||||
|
* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Fall
|
||||||
|
back to general rewriting if we cannot leave an original biv
|
||||||
|
definition alone.
|
||||||
|
|
||||||
2012-12-12 Jakub Jelinek <jakub@redhat.com>
|
2012-12-12 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR target/55659
|
PR target/55659
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2012-12-12 Zdenek Dvorak <ook@ucw.cz>
|
||||||
|
|
||||||
|
PR tree-optimization/55481
|
||||||
|
* gcc.dg/torture/pr55481.c: New testcase.
|
||||||
|
|
||||||
2012-12-12 Steven Bosscher <steven@gcc.gnu.org>
|
2012-12-12 Steven Bosscher <steven@gcc.gnu.org>
|
||||||
Jakub Jelinek <jakub@redhat.com>
|
Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* { dg-do run } */
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
signed char result = 0;
|
||||||
|
int n;
|
||||||
|
for (n = 0; n < 13; ++n)
|
||||||
|
{
|
||||||
|
int tem = result;
|
||||||
|
tem = tem + 31;
|
||||||
|
result = tem;
|
||||||
|
}
|
||||||
|
if (result != -109)
|
||||||
|
__builtin_abort ();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -6088,35 +6088,24 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
|
||||||
if (cand->pos == IP_ORIGINAL
|
if (cand->pos == IP_ORIGINAL
|
||||||
&& cand->incremented_at == use->stmt)
|
&& cand->incremented_at == use->stmt)
|
||||||
{
|
{
|
||||||
tree step, ctype, utype;
|
enum tree_code stmt_code;
|
||||||
enum tree_code incr_code = PLUS_EXPR, old_code;
|
|
||||||
|
|
||||||
gcc_assert (is_gimple_assign (use->stmt));
|
gcc_assert (is_gimple_assign (use->stmt));
|
||||||
gcc_assert (gimple_assign_lhs (use->stmt) == cand->var_after);
|
gcc_assert (gimple_assign_lhs (use->stmt) == cand->var_after);
|
||||||
|
|
||||||
step = cand->iv->step;
|
|
||||||
ctype = TREE_TYPE (step);
|
|
||||||
utype = TREE_TYPE (cand->var_after);
|
|
||||||
if (TREE_CODE (step) == NEGATE_EXPR)
|
|
||||||
{
|
|
||||||
incr_code = MINUS_EXPR;
|
|
||||||
step = TREE_OPERAND (step, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check whether we may leave the computation unchanged.
|
/* Check whether we may leave the computation unchanged.
|
||||||
This is the case only if it does not rely on other
|
This is the case only if it does not rely on other
|
||||||
computations in the loop -- otherwise, the computation
|
computations in the loop -- otherwise, the computation
|
||||||
we rely upon may be removed in remove_unused_ivs,
|
we rely upon may be removed in remove_unused_ivs,
|
||||||
thus leading to ICE. */
|
thus leading to ICE. */
|
||||||
old_code = gimple_assign_rhs_code (use->stmt);
|
stmt_code = gimple_assign_rhs_code (use->stmt);
|
||||||
if (old_code == PLUS_EXPR
|
if (stmt_code == PLUS_EXPR
|
||||||
|| old_code == MINUS_EXPR
|
|| stmt_code == MINUS_EXPR
|
||||||
|| old_code == POINTER_PLUS_EXPR)
|
|| stmt_code == POINTER_PLUS_EXPR)
|
||||||
{
|
{
|
||||||
if (gimple_assign_rhs1 (use->stmt) == cand->var_before)
|
if (gimple_assign_rhs1 (use->stmt) == cand->var_before)
|
||||||
op = gimple_assign_rhs2 (use->stmt);
|
op = gimple_assign_rhs2 (use->stmt);
|
||||||
else if (old_code != MINUS_EXPR
|
else if (gimple_assign_rhs2 (use->stmt) == cand->var_before)
|
||||||
&& gimple_assign_rhs2 (use->stmt) == cand->var_before)
|
|
||||||
op = gimple_assign_rhs1 (use->stmt);
|
op = gimple_assign_rhs1 (use->stmt);
|
||||||
else
|
else
|
||||||
op = NULL_TREE;
|
op = NULL_TREE;
|
||||||
|
@ -6124,23 +6113,12 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
|
||||||
else
|
else
|
||||||
op = NULL_TREE;
|
op = NULL_TREE;
|
||||||
|
|
||||||
if (op
|
if (op && expr_invariant_in_loop_p (data->current_loop, op))
|
||||||
&& (TREE_CODE (op) == INTEGER_CST
|
|
||||||
|| operand_equal_p (op, step, 0)))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Otherwise, add the necessary computations to express
|
comp = get_computation (data->current_loop, use, cand);
|
||||||
the iv. */
|
gcc_assert (comp != NULL_TREE);
|
||||||
op = fold_convert (ctype, cand->var_before);
|
|
||||||
comp = fold_convert (utype,
|
|
||||||
build2 (incr_code, ctype, op,
|
|
||||||
unshare_expr (step)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
comp = get_computation (data->current_loop, use, cand);
|
|
||||||
gcc_assert (comp != NULL_TREE);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (gimple_code (use->stmt))
|
switch (gimple_code (use->stmt))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue