diff mbox

Fix PR44676: fix invariant phi node removal.

Message ID 1291666706-27293-1-git-send-email-sebpop@gmail.com
State New
Headers show

Commit Message

Sebastian Pop Dec. 6, 2010, 8:18 p.m. UTC
Hi,

This backports the change from trunk that fixed PR44676.  I am
regstrapping this fix on amd64-linux.  Ok for the 4.5 branch?

Thanks,
Sebastian

Backport from trunk
http://gcc.gnu.org/viewcvs?view=revision&revision=163105

2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>

	Backport from mainline:
	2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/44676
	* graphite-sese-to-poly.c (loop_entry_phi_arg): Renamed
	phi_arg_in_outermost_loop.
	(remove_simple_copy_phi): Call phi_arg_in_outermost_loop.
	(remove_invariant_phi): Same.
---
 gcc/ChangeLog               |   11 +++++++++++
 gcc/graphite-sese-to-poly.c |   20 +++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

Comments

Sebastian Pop Dec. 6, 2010, 10:53 p.m. UTC | #1
On Mon, Dec 6, 2010 at 14:18, Sebastian Pop <sebpop@gmail.com> wrote:
> Hi,
>
> This backports the change from trunk that fixed PR44676.  I am
> regstrapping this fix on amd64-linux.  Ok for the 4.5 branch?
>

This patch passed bootstrap and test on amd64-linux.

> Thanks,
> Sebastian
>
> Backport from trunk
> http://gcc.gnu.org/viewcvs?view=revision&revision=163105
>
> 2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
>
>        Backport from mainline:
>        2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
>
>        PR tree-optimization/44676
>        * graphite-sese-to-poly.c (loop_entry_phi_arg): Renamed
>        phi_arg_in_outermost_loop.
>        (remove_simple_copy_phi): Call phi_arg_in_outermost_loop.
>        (remove_invariant_phi): Same.
> ---
>  gcc/ChangeLog               |   11 +++++++++++
>  gcc/graphite-sese-to-poly.c |   20 +++++++++++---------
>  2 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 4d52ec8..5d5fd6b 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,14 @@
> +2010-12-06  Sebastian Pop  <sebastian.pop@amd.com>
> +
> +       Backport from mainline:
> +       2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
> +
> +       PR tree-optimization/44676
> +       * graphite-sese-to-poly.c (loop_entry_phi_arg): Renamed
> +       phi_arg_in_outermost_loop.
> +       (remove_simple_copy_phi): Call phi_arg_in_outermost_loop.
> +       (remove_invariant_phi): Same.
> +
>  2010-12-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>        Backport from mainline:
> diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
> index b8f332a..fc28480 100644
> --- a/gcc/graphite-sese-to-poly.c
> +++ b/gcc/graphite-sese-to-poly.c
> @@ -73,21 +73,23 @@ var_used_in_not_loop_header_phi_node (tree var)
>   return result;
>  }
>
> -/* Returns the index of the phi argument corresponding to the initial
> -   value in the loop.  */
> +/* Returns the index of the PHI argument defined in the outermost
> +   loop.  */
>
>  static size_t
> -loop_entry_phi_arg (gimple phi)
> +phi_arg_in_outermost_loop (gimple phi)
>  {
>   loop_p loop = gimple_bb (phi)->loop_father;
> -  size_t i;
> +  size_t i, res = 0;
>
>   for (i = 0; i < gimple_phi_num_args (phi); i++)
>     if (!flow_bb_inside_loop_p (loop, gimple_phi_arg_edge (phi, i)->src))
> -      return i;
> +      {
> +       loop = gimple_phi_arg_edge (phi, i)->src->loop_father;
> +       res = i;
> +      }
>
> -  gcc_unreachable ();
> -  return 0;
> +  return res;
>  }
>
>  /* Removes a simple copy phi node "RES = phi (INIT, RES)" at position
> @@ -98,7 +100,7 @@ remove_simple_copy_phi (gimple_stmt_iterator *psi)
>  {
>   gimple phi = gsi_stmt (*psi);
>   tree res = gimple_phi_result (phi);
> -  size_t entry = loop_entry_phi_arg (phi);
> +  size_t entry = phi_arg_in_outermost_loop (phi);
>   tree init = gimple_phi_arg_def (phi, entry);
>   gimple stmt = gimple_build_assign (res, init);
>   edge e = gimple_phi_arg_edge (phi, entry);
> @@ -118,7 +120,7 @@ remove_invariant_phi (sese region, gimple_stmt_iterator *psi)
>   loop_p loop = loop_containing_stmt (phi);
>   tree res = gimple_phi_result (phi);
>   tree scev = scalar_evolution_in_region (region, loop, res);
> -  size_t entry = loop_entry_phi_arg (phi);
> +  size_t entry = phi_arg_in_outermost_loop (phi);
>   edge e = gimple_phi_arg_edge (phi, entry);
>   tree var;
>   gimple stmt;
> --
> 1.7.1
>
>
Richard Biener Dec. 7, 2010, 10:31 a.m. UTC | #2
On Mon, 6 Dec 2010, Sebastian Pop wrote:

> On Mon, Dec 6, 2010 at 14:18, Sebastian Pop <sebpop@gmail.com> wrote:
> > Hi,
> >
> > This backports the change from trunk that fixed PR44676.  I am
> > regstrapping this fix on amd64-linux.  Ok for the 4.5 branch?
> >
> 
> This patch passed bootstrap and test on amd64-linux.

Ok.

Thanks,
Richard.

> > Thanks,
> > Sebastian
> >
> > Backport from trunk
> > http://gcc.gnu.org/viewcvs?view=revision&revision=163105
> >
> > 2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
> >
> >        Backport from mainline:
> >        2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
> >
> >        PR tree-optimization/44676
> >        * graphite-sese-to-poly.c (loop_entry_phi_arg): Renamed
> >        phi_arg_in_outermost_loop.
> >        (remove_simple_copy_phi): Call phi_arg_in_outermost_loop.
> >        (remove_invariant_phi): Same.
> > ---
> >  gcc/ChangeLog               |   11 +++++++++++
> >  gcc/graphite-sese-to-poly.c |   20 +++++++++++---------
> >  2 files changed, 22 insertions(+), 9 deletions(-)
> >
> > diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> > index 4d52ec8..5d5fd6b 100644
> > --- a/gcc/ChangeLog
> > +++ b/gcc/ChangeLog
> > @@ -1,3 +1,14 @@
> > +2010-12-06  Sebastian Pop  <sebastian.pop@amd.com>
> > +
> > +       Backport from mainline:
> > +       2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
> > +
> > +       PR tree-optimization/44676
> > +       * graphite-sese-to-poly.c (loop_entry_phi_arg): Renamed
> > +       phi_arg_in_outermost_loop.
> > +       (remove_simple_copy_phi): Call phi_arg_in_outermost_loop.
> > +       (remove_invariant_phi): Same.
> > +
> >  2010-12-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> >
> >        Backport from mainline:
> > diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
> > index b8f332a..fc28480 100644
> > --- a/gcc/graphite-sese-to-poly.c
> > +++ b/gcc/graphite-sese-to-poly.c
> > @@ -73,21 +73,23 @@ var_used_in_not_loop_header_phi_node (tree var)
> >   return result;
> >  }
> >
> > -/* Returns the index of the phi argument corresponding to the initial
> > -   value in the loop.  */
> > +/* Returns the index of the PHI argument defined in the outermost
> > +   loop.  */
> >
> >  static size_t
> > -loop_entry_phi_arg (gimple phi)
> > +phi_arg_in_outermost_loop (gimple phi)
> >  {
> >   loop_p loop = gimple_bb (phi)->loop_father;
> > -  size_t i;
> > +  size_t i, res = 0;
> >
> >   for (i = 0; i < gimple_phi_num_args (phi); i++)
> >     if (!flow_bb_inside_loop_p (loop, gimple_phi_arg_edge (phi, i)->src))
> > -      return i;
> > +      {
> > +       loop = gimple_phi_arg_edge (phi, i)->src->loop_father;
> > +       res = i;
> > +      }
> >
> > -  gcc_unreachable ();
> > -  return 0;
> > +  return res;
> >  }
> >
> >  /* Removes a simple copy phi node "RES = phi (INIT, RES)" at position
> > @@ -98,7 +100,7 @@ remove_simple_copy_phi (gimple_stmt_iterator *psi)
> >  {
> >   gimple phi = gsi_stmt (*psi);
> >   tree res = gimple_phi_result (phi);
> > -  size_t entry = loop_entry_phi_arg (phi);
> > +  size_t entry = phi_arg_in_outermost_loop (phi);
> >   tree init = gimple_phi_arg_def (phi, entry);
> >   gimple stmt = gimple_build_assign (res, init);
> >   edge e = gimple_phi_arg_edge (phi, entry);
> > @@ -118,7 +120,7 @@ remove_invariant_phi (sese region, gimple_stmt_iterator *psi)
> >   loop_p loop = loop_containing_stmt (phi);
> >   tree res = gimple_phi_result (phi);
> >   tree scev = scalar_evolution_in_region (region, loop, res);
> > -  size_t entry = loop_entry_phi_arg (phi);
> > +  size_t entry = phi_arg_in_outermost_loop (phi);
> >   edge e = gimple_phi_arg_edge (phi, entry);
> >   tree var;
> >   gimple stmt;
> > --
> > 1.7.1
> >
> >
> 
>
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4d52ec8..5d5fd6b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@ 
+2010-12-06  Sebastian Pop  <sebastian.pop@amd.com>
+
+	Backport from mainline:
+	2010-05-07  Sebastian Pop  <sebastian.pop@amd.com>
+
+	PR tree-optimization/44676
+	* graphite-sese-to-poly.c (loop_entry_phi_arg): Renamed
+	phi_arg_in_outermost_loop.
+	(remove_simple_copy_phi): Call phi_arg_in_outermost_loop.
+	(remove_invariant_phi): Same.
+
 2010-12-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	Backport from mainline:
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index b8f332a..fc28480 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -73,21 +73,23 @@  var_used_in_not_loop_header_phi_node (tree var)
   return result;
 }
 
-/* Returns the index of the phi argument corresponding to the initial
-   value in the loop.  */
+/* Returns the index of the PHI argument defined in the outermost
+   loop.  */
 
 static size_t
-loop_entry_phi_arg (gimple phi)
+phi_arg_in_outermost_loop (gimple phi)
 {
   loop_p loop = gimple_bb (phi)->loop_father;
-  size_t i;
+  size_t i, res = 0;
 
   for (i = 0; i < gimple_phi_num_args (phi); i++)
     if (!flow_bb_inside_loop_p (loop, gimple_phi_arg_edge (phi, i)->src))
-      return i;
+      {
+	loop = gimple_phi_arg_edge (phi, i)->src->loop_father;
+	res = i;
+      }
 
-  gcc_unreachable ();
-  return 0;
+  return res;
 }
 
 /* Removes a simple copy phi node "RES = phi (INIT, RES)" at position
@@ -98,7 +100,7 @@  remove_simple_copy_phi (gimple_stmt_iterator *psi)
 {
   gimple phi = gsi_stmt (*psi);
   tree res = gimple_phi_result (phi);
-  size_t entry = loop_entry_phi_arg (phi);
+  size_t entry = phi_arg_in_outermost_loop (phi);
   tree init = gimple_phi_arg_def (phi, entry);
   gimple stmt = gimple_build_assign (res, init);
   edge e = gimple_phi_arg_edge (phi, entry);
@@ -118,7 +120,7 @@  remove_invariant_phi (sese region, gimple_stmt_iterator *psi)
   loop_p loop = loop_containing_stmt (phi);
   tree res = gimple_phi_result (phi);
   tree scev = scalar_evolution_in_region (region, loop, res);
-  size_t entry = loop_entry_phi_arg (phi);
+  size_t entry = phi_arg_in_outermost_loop (phi);
   edge e = gimple_phi_arg_edge (phi, entry);
   tree var;
   gimple stmt;