public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [graphite] dump reasons why graphite failed to detect a scop
@ 2015-07-24 22:44 Sebastian Pop
  2015-07-25  9:23 ` Tobias Grosser
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Pop @ 2015-07-24 22:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: sebpop, richard.guenther, aditya.k7, tobias, Sebastian Pop

When trying to analyze why Graphite does not handle a loop nest, it is easy to
look in the dumps of -fdump-tree-graphite-all to guess what has to be changed to
catch the loop.  This patch makes the dumps a bit more verbose and useful.
---
 gcc/graphite-scop-detection.c | 72 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 66 insertions(+), 6 deletions(-)

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 686f495..fb7247e 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "graphite-poly.h"
 #include "tree-ssa-propagate.h"
 #include "graphite-scop-detection.h"
+#include "gimple-pretty-print.h"
 
 /* Forward declarations.  */
 static void make_close_phi_nodes_unique (basic_block);
@@ -350,13 +351,31 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
       || (gimple_code (stmt) == GIMPLE_CALL
 	  && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
       || (gimple_code (stmt) == GIMPLE_ASM))
-    return false;
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	{
+	  fprintf (dump_file, "[scop-detection-fail] ");
+	  fprintf (dump_file, "Graphite cannot handle this stmt:\n");
+	  print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
+	}
+
+      return false;
+    }
 
   if (is_gimple_debug (stmt))
     return true;
 
   if (!stmt_has_simple_data_refs_p (outermost_loop, stmt))
-    return false;
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	{
+	  fprintf (dump_file, "[scop-detection-fail] ");
+	  fprintf (dump_file, "Graphite cannot handle data-refs in stmt:\n");
+	  print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
+	}
+
+      return false;
+    }
 
   switch (gimple_code (stmt))
     {
@@ -375,7 +394,16 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
 	      || code == GE_EXPR
 	      || code == EQ_EXPR
 	      || code == NE_EXPR))
-          return false;
+          {
+	    if (dump_file && (dump_flags & TDF_DETAILS))
+	      {
+		fprintf (dump_file, "[scop-detection-fail] ");
+		fprintf (dump_file, "Graphite cannot handle cond stmt:\n");
+		print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
+	      }
+
+	    return false;
+	  }
 
 	for (unsigned i = 0; i < 2; ++i)
 	  {
@@ -383,7 +411,16 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
 	    if (!graphite_can_represent_expr (scop_entry, loop, op)
 		/* We can not handle REAL_TYPE. Failed for pr39260.  */
 		|| TREE_CODE (TREE_TYPE (op)) == REAL_TYPE)
-	      return false;
+	      {
+		if (dump_file && (dump_flags & TDF_DETAILS))
+		  {
+		    fprintf (dump_file, "[scop-detection-fail] ");
+		    fprintf (dump_file, "Graphite cannot represent stmt:\n");
+		    print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
+		  }
+
+		return false;
+	      }
 	  }
 
 	return true;
@@ -395,6 +432,12 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
 
     default:
       /* These nodes cut a new scope.  */
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	{
+	  fprintf (dump_file, "[scop-detection-fail] ");
+	  fprintf (dump_file, "Gimple stmt not handled in Graphite:\n");
+	  print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
+	}
       return false;
     }
 
@@ -488,7 +531,16 @@ scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
 	 with make_forwarder_block.  */
       if (!single_succ_p (bb)
 	  || bb_has_abnormal_pred (single_succ (bb)))
-	result.difficult = true;
+	{
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+	    {
+	      fprintf (dump_file, "[scop-detection-fail] ");
+	      fprintf (dump_file, "BB %d cannot be part of a scop.\n",
+		       bb->index);
+	    }
+
+	  result.difficult = true;
+	}
       else
 	result.exit = single_succ (bb);
 
@@ -509,7 +561,15 @@ scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
 	sinfo = build_scops_1 (bb, outermost_loop, &regions, loop);
 
 	if (!graphite_can_represent_loop (entry_block, loop))
-	  result.difficult = true;
+	  {
+	    if (dump_file && (dump_flags & TDF_DETAILS))
+	      {
+		fprintf (dump_file, "[scop-detection-fail] ");
+		fprintf (dump_file, "Graphite cannot represent loop %d.\n",
+			 loop->num);
+	      }
+	    result.difficult = true;
+	  }
 
 	result.difficult |= sinfo.difficult;
 
-- 
2.1.0.243.g30d45f7

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [graphite] dump reasons why graphite failed to detect a scop
  2015-07-24 22:44 [PATCH] [graphite] dump reasons why graphite failed to detect a scop Sebastian Pop
@ 2015-07-25  9:23 ` Tobias Grosser
  0 siblings, 0 replies; 2+ messages in thread
From: Tobias Grosser @ 2015-07-25  9:23 UTC (permalink / raw)
  To: Sebastian Pop, gcc-patches; +Cc: sebpop, richard.guenther, aditya.k7

On 07/25/2015 12:36 AM, Sebastian Pop wrote:
> When trying to analyze why Graphite does not handle a loop nest, it is easy to
> look in the dumps of -fdump-tree-graphite-all to guess what has to be changed to
> catch the loop.  This patch makes the dumps a bit more verbose and useful.
> ---
>   gcc/graphite-scop-detection.c | 72 +++++++++++++++++++++++++++++++++++++++----
>   1 file changed, 66 insertions(+), 6 deletions(-)

LGTM.

Tobias
>
> diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
> index 686f495..fb7247e 100644
> --- a/gcc/graphite-scop-detection.c
> +++ b/gcc/graphite-scop-detection.c
> @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3.  If not see
>   #include "graphite-poly.h"
>   #include "tree-ssa-propagate.h"
>   #include "graphite-scop-detection.h"
> +#include "gimple-pretty-print.h"
>
>   /* Forward declarations.  */
>   static void make_close_phi_nodes_unique (basic_block);
> @@ -350,13 +351,31 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
>         || (gimple_code (stmt) == GIMPLE_CALL
>   	  && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
>         || (gimple_code (stmt) == GIMPLE_ASM))
> -    return false;
> +    {
> +      if (dump_file && (dump_flags & TDF_DETAILS))
> +	{
> +	  fprintf (dump_file, "[scop-detection-fail] ");
> +	  fprintf (dump_file, "Graphite cannot handle this stmt:\n");
> +	  print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
> +	}
> +
> +      return false;
> +    }
>
>     if (is_gimple_debug (stmt))
>       return true;
>
>     if (!stmt_has_simple_data_refs_p (outermost_loop, stmt))
> -    return false;
> +    {
> +      if (dump_file && (dump_flags & TDF_DETAILS))
> +	{
> +	  fprintf (dump_file, "[scop-detection-fail] ");
> +	  fprintf (dump_file, "Graphite cannot handle data-refs in stmt:\n");
> +	  print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
> +	}
> +
> +      return false;
> +    }
>
>     switch (gimple_code (stmt))
>       {
> @@ -375,7 +394,16 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
>   	      || code == GE_EXPR
>   	      || code == EQ_EXPR
>   	      || code == NE_EXPR))
> -          return false;
> +          {
> +	    if (dump_file && (dump_flags & TDF_DETAILS))
> +	      {
> +		fprintf (dump_file, "[scop-detection-fail] ");
> +		fprintf (dump_file, "Graphite cannot handle cond stmt:\n");
> +		print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
> +	      }
> +
> +	    return false;
> +	  }
>
>   	for (unsigned i = 0; i < 2; ++i)
>   	  {
> @@ -383,7 +411,16 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
>   	    if (!graphite_can_represent_expr (scop_entry, loop, op)
>   		/* We can not handle REAL_TYPE. Failed for pr39260.  */
>   		|| TREE_CODE (TREE_TYPE (op)) == REAL_TYPE)
> -	      return false;
> +	      {
> +		if (dump_file && (dump_flags & TDF_DETAILS))
> +		  {
> +		    fprintf (dump_file, "[scop-detection-fail] ");
> +		    fprintf (dump_file, "Graphite cannot represent stmt:\n");
> +		    print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
> +		  }
> +
> +		return false;
> +	      }
>   	  }
>
>   	return true;
> @@ -395,6 +432,12 @@ stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
>
>       default:
>         /* These nodes cut a new scope.  */
> +      if (dump_file && (dump_flags & TDF_DETAILS))
> +	{
> +	  fprintf (dump_file, "[scop-detection-fail] ");
> +	  fprintf (dump_file, "Gimple stmt not handled in Graphite:\n");
> +	  print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
> +	}
>         return false;
>       }
>
> @@ -488,7 +531,16 @@ scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
>   	 with make_forwarder_block.  */
>         if (!single_succ_p (bb)
>   	  || bb_has_abnormal_pred (single_succ (bb)))
> -	result.difficult = true;
> +	{
> +	  if (dump_file && (dump_flags & TDF_DETAILS))
> +	    {
> +	      fprintf (dump_file, "[scop-detection-fail] ");
> +	      fprintf (dump_file, "BB %d cannot be part of a scop.\n",
> +		       bb->index);
> +	    }
> +
> +	  result.difficult = true;
> +	}
>         else
>   	result.exit = single_succ (bb);
>
> @@ -509,7 +561,15 @@ scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
>   	sinfo = build_scops_1 (bb, outermost_loop, &regions, loop);
>
>   	if (!graphite_can_represent_loop (entry_block, loop))
> -	  result.difficult = true;
> +	  {
> +	    if (dump_file && (dump_flags & TDF_DETAILS))
> +	      {
> +		fprintf (dump_file, "[scop-detection-fail] ");
> +		fprintf (dump_file, "Graphite cannot represent loop %d.\n",
> +			 loop->num);
> +	      }
> +	    result.difficult = true;
> +	  }
>
>   	result.difficult |= sinfo.difficult;
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-25  8:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-24 22:44 [PATCH] [graphite] dump reasons why graphite failed to detect a scop Sebastian Pop
2015-07-25  9:23 ` Tobias Grosser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).