Commit 8b679c9b by Richard Biener Committed by Richard Biener

re PR middle-end/55555 (miscompilation at -O2 (number_of_iterations))

2012-12-18  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/55555
	* tree-ssa-loop-niter.c (idx_infer_loop_bounds): Properly
	analyze evolution of the index for the loop it is used in.
	* tree-scalar-evolution.c (instantiate_scev_name): Take
	inner loop we will be creating a chrec for.  Generalize
	fix for PR40281 and prune invalid SCEVs.
	(instantiate_scev_poly): Likewise - pass down inner loop
	we will be creating a chrec for.
	(instantiate_scev_binary): Take and pass through inner loop.
	(instantiate_array_ref): Likewise.
	(instantiate_scev_convert): Likewise.
	(instantiate_scev_not): Likewise.
	(instantiate_scev_3): Likewise.
	(instantiate_scev_2): Likewise.
	(instantiate_scev_1): Likewise.
	(instantiate_scev_r): Likewise.
	(resolve_mixers): Adjust.
	(instantiate_scev): Likewise.

	* gcc.dg/torture/pr55555.c: New testcase.
	* gcc.dg/vect/vect-iv-11.c: Adjust.

From-SVN: r194578
parent 898be2f3
2012-12-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/55555
* tree-ssa-loop-niter.c (idx_infer_loop_bounds): Properly
analyze evolution of the index for the loop it is used in.
* tree-scalar-evolution.c (instantiate_scev_name): Take
inner loop we will be creating a chrec for. Generalize
fix for PR40281 and prune invalid SCEVs.
(instantiate_scev_poly): Likewise - pass down inner loop
we will be creating a chrec for.
(instantiate_scev_binary): Take and pass through inner loop.
(instantiate_array_ref): Likewise.
(instantiate_scev_convert): Likewise.
(instantiate_scev_not): Likewise.
(instantiate_scev_3): Likewise.
(instantiate_scev_2): Likewise.
(instantiate_scev_1): Likewise.
(instantiate_scev_r): Likewise.
(resolve_mixers): Adjust.
(instantiate_scev): Likewise.
2012-12-18 Jakub Jelinek <jakub@redhat.com>
PR debug/55717
2012-12-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/55555
* gcc.dg/torture/pr55555.c: New testcase.
* gcc.dg/vect/vect-iv-11.c: Adjust.
2012-12-18 Jakub Jelinek <jakub@redhat.com>
PR debug/55717
......
/* { dg-do run } */
double s[4] = { 1.0, 2.0, 3.0, 4.0 }, pol_x[2] = { 5.0, 6.0 };
__attribute__((noinline)) int
foo (void)
{
double coef_x[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int lxp = 0;
if (lxp <= 1)
do
{
double t = pol_x[lxp];
long S;
long l = lxp * 4L - 1;
for (S = 1; S <= 4; S++)
coef_x[S + l] = coef_x[S + l] + s[S - 1] * t;
}
while (lxp++ != 1);
asm volatile ("" : : "r" (coef_x) : "memory");
for (lxp = 0; lxp < 8; lxp++)
if (coef_x[lxp] != ((lxp & 3) + 1) * (5.0 + (lxp >= 4)))
__builtin_abort ();
return 1;
}
int
main ()
{
asm volatile ("" : : : "memory");
if (!foo ())
__builtin_abort ();
return 0;
}
......@@ -3,7 +3,8 @@
#include <stdarg.h>
#include "tree-vect.h"
int main1 (int len)
int __attribute__((noinline,noclone))
main1 (int len)
{
int s = 0;
int i = len;
......
......@@ -2671,7 +2671,12 @@ idx_infer_loop_bounds (tree base, tree *idx, void *dta)
upper = false;
}
ev = instantiate_parameters (loop, analyze_scalar_evolution (loop, *idx));
struct loop *dloop = loop_containing_stmt (data->stmt);
if (!dloop)
return true;
ev = analyze_scalar_evolution (dloop, *idx);
ev = instantiate_parameters (loop, ev);
init = initial_condition (ev);
step = evolution_part_in_loop_num (ev, loop->num);
......
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