diff mbox

Split out SCEV dumping

Message ID alpine.LNX.2.00.1106291626300.810@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener June 29, 2011, 2:27 p.m. UTC
I'm finally annoyed enough about this to do the patch splitting out
SCEV details dumping to a TDF_SCEV (-scev) flag.

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

Richard.

2011-06-29  Richard Guenther  <rguenther@suse.de>

	* doc/invoke.texi: Document -scev dump modifier.
	* tree-pass.h (TDF_SCEV): New dump flag.
	* tree-dump.c (dump_option_value_in): Add scev.
	* tree-chrec.c: Replace all TDF_DETAILS checks with TDF_SCEV.
	* tree-scalar-evolution.c: Likewise.

	* gcc.dg/tree-ssa/loop-17.c: Adjust.

Index: gcc/doc/invoke.texi
===================================================================
*** gcc/doc/invoke.texi	(revision 175630)
--- gcc/doc/invoke.texi	(working copy)
*************** Enable showing the unique ID (@code{DECL
*** 5559,5564 ****
--- 5559,5566 ----
  Enable showing the tree dump for each statement.
  @item eh
  Enable showing the EH region number holding each statement.
+ @item scev
+ Enable showing scalar evolution analysis details.
  @item all
  Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
  and @option{lineno}.
Index: gcc/tree-pass.h
===================================================================
*** gcc/tree-pass.h	(revision 175630)
--- gcc/tree-pass.h	(working copy)
*************** enum tree_dump_index
*** 83,88 ****
--- 83,89 ----
  #define TDF_ALIAS	(1 << 21)	/* display alias information  */
  #define TDF_ENUMERATE_LOCALS (1 << 22)	/* Enumerate locals by uid.  */
  #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
+ #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
  
  
  /* In tree-dump.c */
Index: gcc/tree-dump.c
===================================================================
*** gcc/tree-dump.c	(revision 175630)
--- gcc/tree-dump.c	(working copy)
*************** static const struct dump_option_value_in
*** 823,831 ****
    {"alias", TDF_ALIAS},
    {"nouid", TDF_NOUID},
    {"enumerate_locals", TDF_ENUMERATE_LOCALS},
    {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
  	    | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
! 	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS)},
    {NULL, 0}
  };
  
--- 823,832 ----
    {"alias", TDF_ALIAS},
    {"nouid", TDF_NOUID},
    {"enumerate_locals", TDF_ENUMERATE_LOCALS},
+   {"scev", TDF_SCEV},
    {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
  	    | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
! 	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV)},
    {NULL, 0}
  };
  
Index: gcc/tree-chrec.c
===================================================================
*** gcc/tree-chrec.c	(revision 175630)
--- gcc/tree-chrec.c	(working copy)
*************** chrec_apply (unsigned var,
*** 587,593 ****
        || chrec_contains_symbols_defined_in_loop (chrec, var))
      return chrec_dont_know;
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "(chrec_apply \n");
  
    if (TREE_CODE (x) == INTEGER_CST && SCALAR_FLOAT_TYPE_P (type))
--- 587,593 ----
        || chrec_contains_symbols_defined_in_loop (chrec, var))
      return chrec_dont_know;
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      fprintf (dump_file, "(chrec_apply \n");
  
    if (TREE_CODE (x) == INTEGER_CST && SCALAR_FLOAT_TYPE_P (type))
*************** chrec_apply (unsigned var,
*** 628,634 ****
        break;
      }
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (varying_loop = %d\n", var);
        fprintf (dump_file, ")\n  (chrec = ");
--- 628,634 ----
        break;
      }
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (varying_loop = %d\n", var);
        fprintf (dump_file, ")\n  (chrec = ");
Index: gcc/tree-scalar-evolution.c
===================================================================
*** gcc/tree-scalar-evolution.c	(revision 175630)
--- gcc/tree-scalar-evolution.c	(working copy)
*************** set_scalar_evolution (basic_block instan
*** 572,578 ****
  
    if (dump_file)
      {
!       if (dump_flags & TDF_DETAILS)
  	{
  	  fprintf (dump_file, "(set_scalar_evolution \n");
  	  fprintf (dump_file, "  instantiated_below = %d \n",
--- 572,578 ----
  
    if (dump_file)
      {
!       if (dump_flags & TDF_SCEV)
  	{
  	  fprintf (dump_file, "(set_scalar_evolution \n");
  	  fprintf (dump_file, "  instantiated_below = %d \n",
*************** get_scalar_evolution (basic_block instan
*** 600,606 ****
  
    if (dump_file)
      {
!       if (dump_flags & TDF_DETAILS)
  	{
  	  fprintf (dump_file, "(get_scalar_evolution \n");
  	  fprintf (dump_file, "  (scalar = ");
--- 600,606 ----
  
    if (dump_file)
      {
!       if (dump_flags & TDF_SCEV)
  	{
  	  fprintf (dump_file, "(get_scalar_evolution \n");
  	  fprintf (dump_file, "  (scalar = ");
*************** get_scalar_evolution (basic_block instan
*** 628,634 ****
        break;
      }
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (scalar_evolution = ");
        print_generic_expr (dump_file, res, 0);
--- 628,634 ----
        break;
      }
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (scalar_evolution = ");
        print_generic_expr (dump_file, res, 0);
*************** add_to_evolution (unsigned loop_nb, tree
*** 861,867 ****
      /* This should not happen.  */
      return chrec_dont_know;
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "(add_to_evolution \n");
        fprintf (dump_file, "  (loop_nb = %d)\n", loop_nb);
--- 861,867 ----
      /* This should not happen.  */
      return chrec_dont_know;
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "(add_to_evolution \n");
        fprintf (dump_file, "  (loop_nb = %d)\n", loop_nb);
*************** add_to_evolution (unsigned loop_nb, tree
*** 879,885 ****
  
    res = add_to_evolution_1 (loop_nb, chrec_before, to_add, at_stmt);
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (res = ");
        print_generic_expr (dump_file, res, 0);
--- 879,885 ----
  
    res = add_to_evolution_1 (loop_nb, chrec_before, to_add, at_stmt);
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (res = ");
        print_generic_expr (dump_file, res, 0);
*************** get_loop_exit_condition (const struct lo
*** 905,911 ****
    gimple res = NULL;
    edge exit_edge = single_exit (loop);
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "(get_loop_exit_condition \n  ");
  
    if (exit_edge)
--- 905,911 ----
    gimple res = NULL;
    edge exit_edge = single_exit (loop);
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      fprintf (dump_file, "(get_loop_exit_condition \n  ");
  
    if (exit_edge)
*************** get_loop_exit_condition (const struct lo
*** 917,923 ****
  	res = stmt;
      }
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        print_gimple_stmt (dump_file, res, 0, 0);
        fprintf (dump_file, ")\n");
--- 917,923 ----
  	res = stmt;
      }
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        print_gimple_stmt (dump_file, res, 0, 0);
        fprintf (dump_file, ")\n");
*************** analyze_evolution_in_loop (gimple loop_p
*** 1461,1467 ****
    struct loop *loop = loop_containing_stmt (loop_phi_node);
    basic_block bb;
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "(analyze_evolution_in_loop \n");
        fprintf (dump_file, "  (loop_phi_node = ");
--- 1461,1467 ----
    struct loop *loop = loop_containing_stmt (loop_phi_node);
    basic_block bb;
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "(analyze_evolution_in_loop \n");
        fprintf (dump_file, "  (loop_phi_node = ");
*************** analyze_evolution_in_loop (gimple loop_p
*** 1517,1523 ****
        evolution_function = chrec_merge (evolution_function, ev_fn);
      }
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (evolution_function = ");
        print_generic_expr (dump_file, evolution_function, 0);
--- 1517,1523 ----
        evolution_function = chrec_merge (evolution_function, ev_fn);
      }
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (evolution_function = ");
        print_generic_expr (dump_file, evolution_function, 0);
*************** analyze_initial_condition (gimple loop_p
*** 1541,1547 ****
    tree init_cond = chrec_not_analyzed_yet;
    struct loop *loop = loop_containing_stmt (loop_phi_node);
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "(analyze_initial_condition \n");
        fprintf (dump_file, "  (loop_phi_node = \n");
--- 1541,1547 ----
    tree init_cond = chrec_not_analyzed_yet;
    struct loop *loop = loop_containing_stmt (loop_phi_node);
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "(analyze_initial_condition \n");
        fprintf (dump_file, "  (loop_phi_node = \n");
*************** analyze_initial_condition (gimple loop_p
*** 1593,1599 ****
  	init_cond = res;
      }
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (init_cond = ");
        print_generic_expr (dump_file, init_cond, 0);
--- 1593,1599 ----
  	init_cond = res;
      }
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (init_cond = ");
        print_generic_expr (dump_file, init_cond, 0);
*************** analyze_scalar_evolution (struct loop *l
*** 1942,1948 ****
  {
    tree res;
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "(analyze_scalar_evolution \n");
        fprintf (dump_file, "  (loop_nb = %d)\n", loop->num);
--- 1942,1948 ----
  {
    tree res;
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "(analyze_scalar_evolution \n");
        fprintf (dump_file, "  (loop_nb = %d)\n", loop->num);
*************** analyze_scalar_evolution (struct loop *l
*** 1954,1960 ****
    res = get_scalar_evolution (block_before_loop (loop), var);
    res = analyze_scalar_evolution_1 (loop, var, res);
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, ")\n");
  
    return res;
--- 1954,1960 ----
    res = get_scalar_evolution (block_before_loop (loop), var);
    res = analyze_scalar_evolution_1 (loop, var, res);
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      fprintf (dump_file, ")\n");
  
    return res;
*************** instantiate_scev (basic_block instantiat
*** 2700,2706 ****
    tree res;
    htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info);
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "(instantiate_scev \n");
        fprintf (dump_file, "  (instantiate_below = %d)\n", instantiate_below->index);
--- 2700,2706 ----
    tree res;
    htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info);
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "(instantiate_scev \n");
        fprintf (dump_file, "  (instantiate_below = %d)\n", instantiate_below->index);
*************** instantiate_scev (basic_block instantiat
*** 2713,2719 ****
    res = instantiate_scev_r (instantiate_below, evolution_loop, chrec, false,
  			    cache, 0);
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (res = ");
        print_generic_expr (dump_file, res, 0);
--- 2713,2719 ----
    res = instantiate_scev_r (instantiate_below, evolution_loop, chrec, false,
  			    cache, 0);
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (res = ");
        print_generic_expr (dump_file, res, 0);
*************** number_of_latch_executions (struct loop
*** 2779,2785 ****
  
    may_be_zero = NULL_TREE;
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "(number_of_iterations_in_loop = \n");
  
    res = chrec_dont_know;
--- 2779,2785 ----
  
    may_be_zero = NULL_TREE;
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      fprintf (dump_file, "(number_of_iterations_in_loop = \n");
  
    res = chrec_dont_know;
*************** number_of_latch_executions (struct loop
*** 2804,2810 ****
    else
      res = chrec_dont_know;
  
!   if (dump_file && (dump_flags & TDF_DETAILS))
      {
        fprintf (dump_file, "  (set_nb_iterations_in_loop = ");
        print_generic_expr (dump_file, res, 0);
--- 2804,2810 ----
    else
      res = chrec_dont_know;
  
!   if (dump_file && (dump_flags & TDF_SCEV))
      {
        fprintf (dump_file, "  (set_nb_iterations_in_loop = ");
        print_generic_expr (dump_file, res, 0);

Comments

Sebastian Pop June 29, 2011, 4:11 p.m. UTC | #1
On Wed, Jun 29, 2011 at 09:27, Richard Guenther <rguenther@suse.de> wrote:
>
> I'm finally annoyed enough about this to do the patch splitting out
> SCEV details dumping to a TDF_SCEV (-scev) flag.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Looks very good.  Thanks for this cleanup.

Sebastian
diff mbox

Patch

Index: gcc/testsuite/gcc.dg/tree-ssa/loop-17.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/loop-17.c	(revision 175631)
+++ gcc/testsuite/gcc.dg/tree-ssa/loop-17.c	(working copy)
@@ -15,5 +15,5 @@  int foo (int *p)
   return i;
 }
 
-/* { dg-final { scan-tree-dump "set_nb_iterations_in_loop = 1" "sccp" } } */
+/* { dg-final { scan-tree-dump "# of iterations 1, bounded by 1" "sccp" } } */
 /* { dg-final { cleanup-tree-dump "sccp" } } */