diff options
author | Richard Guenther <rguenther@suse.de> | 2010-01-09 12:04:17 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-01-09 12:04:17 +0000 |
commit | 73c865fab7acc35517e28e09dc417db6a5697f12 (patch) | |
tree | ee8a9e64e051a1d0c3d8486cfd0df2a03b079041 /gcc/tree-scalar-evolution.c | |
parent | 0462fd5e01941647bfb8b3706443fd9de8b585c2 (diff) | |
download | gcc-73c865fab7acc35517e28e09dc417db6a5697f12.zip gcc-73c865fab7acc35517e28e09dc417db6a5697f12.tar.gz gcc-73c865fab7acc35517e28e09dc417db6a5697f12.tar.bz2 |
re PR middle-end/42512 (integer wrong code bug with loop)
2010-01-09 Richard Guenther <rguenther@suse.de>
PR middle-end/42512
* tree-scalar-evolution.c (interpret_loop_phi): Make sure
the evolution is compatible with the initial condition.
* gcc.c-torture/execute/pr42512.c: New testcase.
From-SVN: r155757
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 087ba79..3ebc54e 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1642,6 +1642,23 @@ interpret_loop_phi (struct loop *loop, gimple loop_phi_node) init_cond = analyze_initial_condition (loop_phi_node); res = analyze_evolution_in_loop (loop_phi_node, init_cond); + /* Verify we maintained the correct initial condition throughout + possible conversions in the SSA chain. */ + if (res != chrec_dont_know) + { + tree new_init = res; + if (CONVERT_EXPR_P (res) + && TREE_CODE (TREE_OPERAND (res, 0)) == POLYNOMIAL_CHREC) + new_init = fold_convert (TREE_TYPE (res), + CHREC_LEFT (TREE_OPERAND (res, 0))); + else if (TREE_CODE (res) == POLYNOMIAL_CHREC) + new_init = CHREC_LEFT (res); + STRIP_USELESS_TYPE_CONVERSION (new_init); + gcc_assert (TREE_CODE (new_init) != POLYNOMIAL_CHREC); + if (!operand_equal_p (init_cond, new_init, 0)) + return chrec_dont_know; + } + return res; } |