aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pop <spop@gcc.gnu.org>2010-03-02 10:22:30 +0000
committerSebastian Pop <spop@gcc.gnu.org>2010-03-02 10:22:30 +0000
commit61226dc8a6eb0371d39f437813fbb3279d87f723 (patch)
treeb0076122adc5adf6b7a8bd73fa49ac375ec186db
parentef74edbdd8c9a674de3b7a0a20784de3d6bbb4d8 (diff)
downloadgcc-61226dc8a6eb0371d39f437813fbb3279d87f723.zip
gcc-61226dc8a6eb0371d39f437813fbb3279d87f723.tar.gz
gcc-61226dc8a6eb0371d39f437813fbb3279d87f723.tar.bz2
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
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr42640.c58
-rw-r--r--gcc/tree-loop-distribution.c4
4 files changed, 75 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 47e217f..9e9755a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6e72856..63ceb9a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr42640.c b/gcc/testsuite/gcc.dg/tree-ssa/pr42640.c
new file mode 100644
index 0000000..70807c0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr42640.c
@@ -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;
+}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 13ac7ea..920ab8c 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -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. */