This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa]: Dump file option names and small DCE fix


In trying out DCE, I noticed that it fcloses the dump_file in the same if block it opens it in, so nothing besides a pre-dce dump gets printed to it.

I fixed this, and took the time to canonicalize the dump option/file/enum names as we talked about earlier.
They now match the -f option. So we have -ftree-ssa-ccp and -fdump-tree-ssa-ccp, and the enum is TDI_ssa_ccp.

After doing this, on a simple example, DCE eliminated everything.
The reason was that it doesn't consider return_stmt's inherently necessary.

Once i made it do so, at least that example had only the real dead code eliminated.


Bootstrapped and tested.

Diego, Okay?

2002-09-18 Daniel Berlin <dberlin@dberlin.org>

* tree-dump.c (dump_files): Use dump-tree-ssa-??? for the
option names and "ssa-???" for the dump files.

* tree.h: TDI_ccp and TDI_dce -> TDI_ssa_ccp and TDI_ssa_dce.

* tree-ssa-ccp.c: TDI_ccp->TDI_ssa_ccp.

* tree-ssa-dce.c (tree_ssa_eliminate_dead_code): Don't fclose the
dump file. Use dump_end.
TDI_dce->TDI_ssa_dce.
Return statements are always necessary.

Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.6.2.10
diff -c -3 -p -w -B -b -r1.6.2.10 tree-dump.c
*** tree-dump.c 18 Sep 2002 22:50:48 -0000 1.6.2.10
--- tree-dump.c 18 Sep 2002 22:55:00 -0000
*************** static struct dump_file_info dump_files[
*** 664,672 ****
{".cfg", "dump-tree-cfg", 0, 0},
{".dot", "dump-tree-dot", 0, 0},
{".ssa", "dump-tree-ssa", 0, 0},
! {".ccp", "dump-tree-ccp", 0, 0},
! {".ssapre", "dump-tree-ssapre", 0, 0},
! {".dce", "dump-tree-dce", 0, 0},
{".optimized", "dump-tree-optimized", 0, 0},
{".xml", "dump-call-graph", 0, 0},
};
--- 664,672 ----
{".cfg", "dump-tree-cfg", 0, 0},
{".dot", "dump-tree-dot", 0, 0},
{".ssa", "dump-tree-ssa", 0, 0},
! {".ssa-ccp", "dump-tree-ssa-ccp", 0, 0},
! {".ssa-pre", "dump-tree-ssa-pre", 0, 0},
! {".ssa-dce", "dump-tree-ssa-dce", 0, 0},
{".optimized", "dump-tree-optimized", 0, 0},
{".xml", "dump-call-graph", 0, 0},
};
*************** dump_enable_all_ssa ()
*** 764,771 ****
dump_files[TDI_cfg].state = -1;
dump_files[TDI_dot].state = -1;
dump_files[TDI_ssa_pre].state = -1;
! dump_files[TDI_ccp].state = -1;
! dump_files[TDI_dce].state = -1;
dump_files[TDI_ssa].state = -1;
dump_files[TDI_simple].state = -1;
}
--- 764,771 ----
dump_files[TDI_cfg].state = -1;
dump_files[TDI_dot].state = -1;
dump_files[TDI_ssa_pre].state = -1;
! dump_files[TDI_ssa_ccp].state = -1;
! dump_files[TDI_ssa_dce].state = -1;
dump_files[TDI_ssa].state = -1;
dump_files[TDI_simple].state = -1;
}
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.13
diff -c -3 -p -w -B -b -r1.342.2.13 tree.h
*** tree.h 17 Sep 2002 22:04:26 -0000 1.342.2.13
--- tree.h 18 Sep 2002 22:55:01 -0000
*************** enum tree_dump_index
*** 3080,3090 ****
TDI_dot, /* create a dot graph file for each
function's flowgraph. */
TDI_ssa, /* dump SSA information for each function. */
! TDI_ccp, /* dump SSA CCP information for each
function. */
TDI_ssa_pre, /* dump SSA PRE information for each
function. */
! TDI_dce, /* dump SSA DCE information for each
function. */
TDI_optimized, /* dump each function after optimizing it */
TDI_xml, /* dump function call graph. */
--- 3080,3090 ----
TDI_dot, /* create a dot graph file for each
function's flowgraph. */
TDI_ssa, /* dump SSA information for each function. */
! TDI_ssa_ccp, /* dump SSA CCP information for each
function. */
TDI_ssa_pre, /* dump SSA PRE information for each
function. */
! TDI_ssa_dce, /* dump SSA DCE information for each
function. */
TDI_optimized, /* dump each function after optimizing it */
TDI_xml, /* dump function call graph. */
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.1
diff -c -3 -p -w -B -b -r1.1.2.1 tree-ssa-dce.c
*** tree-ssa-dce.c 17 Sep 2002 22:04:26 -0000 1.1.2.1
--- tree-ssa-dce.c 18 Sep 2002 22:55:01 -0000
*************** tree_ssa_eliminate_dead_code (fndecl)
*** 152,158 ****
VARRAY_TREE_INIT (worklist, 64, "work list");

/* Debugging dumps. */
! dump_file = dump_begin (TDI_dce, &dump_flags);
if (dump_file)
{
fprintf (dump_file, "%s\n",
--- 152,158 ----
VARRAY_TREE_INIT (worklist, 64, "work list");

/* Debugging dumps. */
! dump_file = dump_begin (TDI_ssa_dce, &dump_flags);
if (dump_file)
{
fprintf (dump_file, "%s\n",
*************** tree_ssa_eliminate_dead_code (fndecl)
*** 163,169 ****
else
print_c_tree (dump_file, fnbody);

- fclose (dump_file);
}

if (dump_file && (dump_flags & TDF_DETAILS))
--- 163,168 ----
*************** tree_ssa_eliminate_dead_code (fndecl)
*** 187,192 ****
--- 186,198 ----
t = TREE_CHAIN (t);
continue;
}
+ if (TREE_CODE (t) == RETURN_STMT)
+ {
+ mark_necessary (t);
+ VARRAY_PUSH_TREE (worklist, t);
+ t = TREE_CHAIN (t);
+ continue;
+ }

/* FIXME Weird guard -- seems to be necessary. */
if (!tree_annotation (t))
*************** tree_ssa_eliminate_dead_code (fndecl)
*** 321,325 ****
--- 327,333 ----
fprintf (dump_file, "New translation unit:\n");
print_c_tree (dump_file, fnbody);
}
+ if (dump_file)
+ dump_end (TDI_ssa_dce, dump_file);
print_stats ();
}
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.17
diff -c -3 -p -w -B -b -r1.1.2.17 tree-ssa-ccp.c
*** tree-ssa-ccp.c 13 Sep 2002 17:46:52 -0000 1.1.2.17
--- tree-ssa-ccp.c 18 Sep 2002 22:57:12 -0000
*************** tree_ssa_ccp (fndecl)
*** 201,207 ****
print_c_tree (dump_file, fnbody);

fprintf (dump_file, "\n");
! dump_end (TDI_ccp, dump_file);
}

finalize ();
--- 201,207 ----
print_c_tree (dump_file, fnbody);

fprintf (dump_file, "\n");
! dump_end (TDI_ssa_ccp, dump_file);
}

finalize ();
*************** initialize ()
*** 917,923 ****
edge curredge;

/* Initialize debugging dumps. */
! dump_file = dump_begin (TDI_ccp, &dump_flags);

/* Build an edge list from the CFG. */
edges = create_edge_list ();
--- 917,923 ----
edge curredge;

/* Initialize debugging dumps. */
! dump_file = dump_begin (TDI_ssa_ccp, &dump_flags);

/* Build an edge list from the CFG. */
edges = create_edge_list ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]