Fix PR83435

Message ID alpine.LSU.2.20.1801111439450.32271@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix PR83435
Related show

Commit Message

Richard Biener Jan. 11, 2018, 1:41 p.m.
The following fixes VRP to be less susceptible to TREE_OVERFLOW in the
GIMPLE IL (which we don't really want...).  It also fixes fallout from
my earlier graphite fixes (look better at this stage than ignoring
fake edges when computing loop exists everywhere...).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2018-01-11  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/83435
	* graphite.c (canonicalize_loop_form): Ignore fake loop exit edges.
	* graphite-scop-detection.c (scop_detection::get_sese): Likewise.
	* tree-vrp.c (add_assert_info): Drop TREE_OVERFLOW if they appear.

	* gcc.dg/graphite/pr83435.c: New testcase.

Comments

Szabolcs Nagy Jan. 15, 2018, 3:14 p.m. | #1
On 11/01/18 13:41, Richard Biener wrote:
> 2018-01-11  Richard Biener  <rguenther@suse.de>
> 
> 	PR tree-optimization/83435
> 	* graphite.c (canonicalize_loop_form): Ignore fake loop exit edges.
> 	* graphite-scop-detection.c (scop_detection::get_sese): Likewise.
> 	* tree-vrp.c (add_assert_info): Drop TREE_OVERFLOW if they appear.
> 
> 	* gcc.dg/graphite/pr83435.c: New testcase.

this test case fails on baremetal targets for me with

xgcc: error: unrecognized command line option '-pthread'


> Index: gcc/testsuite/gcc.dg/graphite/pr83435.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/graphite/pr83435.c	(nonexistent)
> +++ gcc/testsuite/gcc.dg/graphite/pr83435.c	(working copy)
> @@ -0,0 +1,25 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -ftree-parallelize-loops=2 -floop-parallelize-all" } */
> +
> +int yj, ax;
> +
> +void
> +gf (signed char mp)
> +{
> +  int *dh = &yj;
> +
> +  for (;;)
> +    {
> +      signed char sb;
> +
> +      for (sb = 0; sb < 1; sb -= 8)
> +	{
> +	}
> +
> +      mp &= mp <= sb;
> +      if (mp == 0)
> +	dh = &ax;
> +      mp = 0;
> +      *dh = 0;
> +    }
> +}
>
Richard Biener Jan. 16, 2018, 8:08 a.m. | #2
On Mon, 15 Jan 2018, Szabolcs Nagy wrote:

> On 11/01/18 13:41, Richard Biener wrote:
> > 2018-01-11  Richard Biener  <rguenther@suse.de>
> > 
> > 	PR tree-optimization/83435
> > 	* graphite.c (canonicalize_loop_form): Ignore fake loop exit edges.
> > 	* graphite-scop-detection.c (scop_detection::get_sese): Likewise.
> > 	* tree-vrp.c (add_assert_info): Drop TREE_OVERFLOW if they appear.
> > 
> > 	* gcc.dg/graphite/pr83435.c: New testcase.
> 
> this test case fails on baremetal targets for me with
> 
> xgcc: error: unrecognized command line option '-pthread'

Fixed as follows.

Richard.

2018-01-16  Richard Biener  <rguenther@suse.de>

	* gcc.dg/graphite/pr83435.c: Restrict to target pthread.

Index: gcc/testsuite/gcc.dg/graphite/pr83435.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/pr83435.c	(revision 256722)
+++ gcc/testsuite/gcc.dg/graphite/pr83435.c	(working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target pthread } } */
 /* { dg-options "-O -ftree-parallelize-loops=2 -floop-parallelize-all" } */
 
 int yj, ax;

> 
> > Index: gcc/testsuite/gcc.dg/graphite/pr83435.c
> > ===================================================================
> > --- gcc/testsuite/gcc.dg/graphite/pr83435.c	(nonexistent)
> > +++ gcc/testsuite/gcc.dg/graphite/pr83435.c	(working copy)
> > @@ -0,0 +1,25 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-O -ftree-parallelize-loops=2 -floop-parallelize-all" } */
> > +
> > +int yj, ax;
> > +
> > +void
> > +gf (signed char mp)
> > +{
> > +  int *dh = &yj;
> > +
> > +  for (;;)
> > +    {
> > +      signed char sb;
> > +
> > +      for (sb = 0; sb < 1; sb -= 8)
> > +	{
> > +	}
> > +
> > +      mp &= mp <= sb;
> > +      if (mp == 0)
> > +	dh = &ax;
> > +      mp = 0;
> > +      *dh = 0;
> > +    }
> > +}
> > 
> 
>

Patch

Index: gcc/graphite.c
===================================================================
--- gcc/graphite.c	(revision 256479)
+++ gcc/graphite.c	(working copy)
@@ -324,7 +324,7 @@  canonicalize_loop_form (void)
   FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
     {
       edge e = single_exit (loop);
-      if (!e || (e->flags & EDGE_COMPLEX))
+      if (!e || (e->flags & (EDGE_COMPLEX|EDGE_FAKE)))
 	continue;
 
       canonicalize_loop_closed_ssa (loop, e);
Index: gcc/graphite-scop-detection.c
===================================================================
--- gcc/graphite-scop-detection.c	(revision 256479)
+++ gcc/graphite-scop-detection.c	(working copy)
@@ -428,7 +428,7 @@  scop_detection::get_sese (loop_p loop)
 
   edge scop_begin = loop_preheader_edge (loop);
   edge scop_end = single_exit (loop);
-  if (!scop_end || (scop_end->flags & EDGE_COMPLEX))
+  if (!scop_end || (scop_end->flags & (EDGE_COMPLEX|EDGE_FAKE)))
     return invalid_sese;
   /* Include the BB with the loop-closed SSA PHI nodes.
      canonicalize_loop_closed_ssa makes sure that is in proper shape.  */
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 256479)
+++ gcc/tree-vrp.c	(working copy)
@@ -2786,6 +2786,8 @@  add_assert_info (vec<assert_info> &asser
   assert_info info;
   info.comp_code = comp_code;
   info.name = name;
+  if (TREE_OVERFLOW_P (val))
+    val = drop_tree_overflow (val);
   info.val = val;
   info.expr = expr;
   asserts.safe_push (info);
Index: gcc/testsuite/gcc.dg/graphite/pr83435.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/pr83435.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/graphite/pr83435.c	(working copy)
@@ -0,0 +1,25 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-parallelize-loops=2 -floop-parallelize-all" } */
+
+int yj, ax;
+
+void
+gf (signed char mp)
+{
+  int *dh = &yj;
+
+  for (;;)
+    {
+      signed char sb;
+
+      for (sb = 0; sb < 1; sb -= 8)
+	{
+	}
+
+      mp &= mp <= sb;
+      if (mp == 0)
+	dh = &ax;
+      mp = 0;
+      *dh = 0;
+    }
+}