Fix PR42640: Correctly initialize the value of the new induction variable.

2010-03-02  Reza Yazdani  <reza.yazdani@amd.com>

	PR middle-end/42640
	* tree-loop-distribution.c (update_phis_for_loop_copy): Replaced
	the assignment from the new induction variable to the assignment
	of the value from the original loop PHI function.

	* gcc.dg/tree-ssa/pr42640.c: New.

From-SVN: r157161
This commit is contained in:
Sebastian Pop 2010-03-02 10:22:30 +00:00
parent ef74edbdd8
commit 61226dc8a6
4 changed files with 75 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2010-03-02 Reza Yazdani <reza.yazdani@amd.com>
PR middle-end/42640
* tree-loop-distribution.c (update_phis_for_loop_copy): Replaced
the assignment from the new induction variable to the assignment
of the value from the original loop PHI function.
2010-03-01 Janis Johnson <janis187@us.ibm.com>
Daniel Jacobowitz <dan@codesourcery.com>
@ -27,7 +34,7 @@
2010-03-01 Christian Bruel <christian.bruel@st.com>
* except.c (dw2_build_landing_pads): set LABEL_PRESERVE_P.
2010-03-01 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/linux64.h (ASM_SPEC): Use SPEC_32 and SPEC_64.
@ -47,7 +54,7 @@
64-bit, SPARC and x86.
(sol_gt_pch_get_address): New function.
2010-03-01 Marco Poletti <poletti.marco@gmail.com>
2010-03-01 Marco Poletti <poletti.marco@gmail.com>
* toplev.h (inform_n, error_n): Declare.
* diagnostic.c (inform_n, error_n): New function.
@ -133,7 +140,7 @@
* doc/standards.texi: Likewise.
* doc/extend.texi: Likewise.
* doc/trouble.texi: Likewise.
* doc/cppopts.texi: Likewise.
* doc/cppopts.texi: Likewise.
* doc/install.texi: Likewise.
* c.opt (std=c90,std=gnu90): New options.
* c-opts.c (c_common_handle_option): Handle them.

View File

@ -1,3 +1,8 @@
2010-03-02 Reza Yazdani <reza.yazdani@amd.com>
PR middle-end/42640
* gcc.dg/tree-ssa/pr42640.c: New.
2010-03-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43220

View File

@ -0,0 +1,58 @@
/* { dg-do run } */
/* { dg-options "-O2 -ftree-loop-distribution" } */
/* Checks if loop distribution works correctly if the subscript used
is assigned to a loop invariant value. */
extern void abort (void);
struct S { int a; int b; int c; };
int get_rr_node_index (int i)
{
return i;
}
struct S nodes[8];
struct S *rr_node = nodes;
volatile int io_rat = 2;
void
doit (int i, int j)
{
int s_node, p_node, inode, ipad, iloop;
for (ipad = 0; ipad < io_rat; ipad++)
{
p_node = get_rr_node_index (ipad+2);
inode = get_rr_node_index (ipad);
for (iloop = 1; iloop <= 2; iloop++)
{
rr_node[inode].a = i;
rr_node[inode].b = j;
rr_node[inode].c = ipad;
inode = p_node;
}
}
}
int
main ()
{
int i;
doit (1, 2);
if (rr_node[0].a != rr_node[1].a
|| rr_node[2].a != rr_node[3].a
|| rr_node[1].a != 1
|| rr_node[0].b != rr_node[1].b
|| rr_node[2].b != rr_node[3].b
|| rr_node[1].b != 2
|| rr_node[0].c != 0
|| rr_node[1].c != 1
|| rr_node[2].c != 0
|| rr_node[3].c != 1)
abort ();
return 0;
}

View File

@ -118,8 +118,8 @@ update_phis_for_loop_copy (struct loop *orig_loop, struct loop *new_loop)
if (!new_ssa_name)
/* This only happens if there are no definitions inside the
loop. Use the phi_result in this case. */
new_ssa_name = PHI_RESULT (phi_new);
loop. Use the the invariant in the new loop as is. */
new_ssa_name = def;
}
else
/* Could be an integer. */