diff options
author | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-01 17:59:06 +0000 |
---|---|---|
committer | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-01 17:59:06 +0000 |
commit | 5e733b0261a2650d1574be49c7e155768003c59d (patch) | |
tree | 126cecfe4e30597e3e21ba835c4893c2e3f19195 /gcc/tree-ssa-dce.c | |
parent | 3cc68dd82f269732a8dc175645f1ea36fd8bcd86 (diff) | |
download | gcc-5e733b0261a2650d1574be49c7e155768003c59d.tar.gz |
2005-03-01 Daniel Berlin <dberlin@dberlin.org>
* Makefile.in (tree-ssa-sink.o): New.
(OBJS-common): Add tree-ssa-sink.o.
* common.opt: Add -ftree-sink
* opts.c (decode_options): flag_tree_sink is set at O1 or higher.
* timevar.def (TV_TREE_SINK): new timevar.
* tree-flow.h (is_hidden_global_store): Prototype.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_sink_code.
* tree-pass.h (pass_sink_code): New.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Move checking
for non-obvious global store store to is_hidden_global_store, and
call that new function.
* tree-ssa-sink.c: New file.
* doc/invoke.texi: Document -fdump-tree-sink and -ftree-sink.
* doc/passes.texi: Document forward store motion.
* testsuite/gcc.dg/tree-ssa/ssa-sink-1.c: New test
* testsuite/gcc.dg/tree-ssa/ssa-sink-2.c: New test
* testsuite/gcc.dg/tree-ssa/ssa-sink-3.c: New test
* testsuite/gcc.dg/tree-ssa/ssa-sink-4.c: New test
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95750 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dce.c')
-rw-r--r-- | gcc/tree-ssa-dce.c | 76 |
1 files changed, 3 insertions, 73 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 16b9d480a49..69408e8cd7d 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -277,8 +277,6 @@ mark_operand_necessary (tree op, bool phionly) static void mark_stmt_if_obviously_necessary (tree stmt, bool aggressive) { - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; stmt_ann_t ann; tree op, def; ssa_op_iter iter; @@ -368,78 +366,10 @@ mark_stmt_if_obviously_necessary (tree stmt, bool aggressive) return; } } - - /* Check virtual definitions. If we get here, the only virtual - definitions we should see are those generated by assignment - statements. */ - v_may_defs = V_MAY_DEF_OPS (ann); - v_must_defs = V_MUST_DEF_OPS (ann); - if (NUM_V_MAY_DEFS (v_may_defs) > 0 || NUM_V_MUST_DEFS (v_must_defs) > 0) + if (is_hidden_global_store (stmt)) { - tree lhs; - - gcc_assert (TREE_CODE (stmt) == MODIFY_EXPR); - - /* Note that we must not check the individual virtual operands - here. In particular, if this is an aliased store, we could - end up with something like the following (SSA notation - redacted for brevity): - - foo (int *p, int i) - { - int x; - p_1 = (i_2 > 3) ? &x : p_1; - - # x_4 = V_MAY_DEF <x_3> - *p_1 = 5; - - return 2; - } - - Notice that the store to '*p_1' should be preserved, if we - were to check the virtual definitions in that store, we would - not mark it needed. This is because 'x' is not a global - variable. - - Therefore, we check the base address of the LHS. If the - address is a pointer, we check if its name tag or type tag is - a global variable. Otherwise, we check if the base variable - is a global. */ - lhs = TREE_OPERAND (stmt, 0); - if (REFERENCE_CLASS_P (lhs)) - lhs = get_base_address (lhs); - - if (lhs == NULL_TREE) - { - /* If LHS is NULL, it means that we couldn't get the base - address of the reference. In which case, we should not - remove this store. */ - mark_stmt_necessary (stmt, true); - } - else if (DECL_P (lhs)) - { - /* If the store is to a global symbol, we need to keep it. */ - if (is_global_var (lhs)) - mark_stmt_necessary (stmt, true); - } - else if (INDIRECT_REF_P (lhs)) - { - tree ptr = TREE_OPERAND (lhs, 0); - struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr); - tree nmt = (pi) ? pi->name_mem_tag : NULL_TREE; - tree tmt = var_ann (SSA_NAME_VAR (ptr))->type_mem_tag; - - /* If either the name tag or the type tag for PTR is a - global variable, then the store is necessary. */ - if ((nmt && is_global_var (nmt)) - || (tmt && is_global_var (tmt))) - { - mark_stmt_necessary (stmt, true); - return; - } - } - else - gcc_unreachable (); + mark_stmt_necessary (stmt, true); + return; } return; |