Commit 0fc6c492 by Daniel Berlin

re PR tree-optimization/19624 (PRE pessimizes ivopts)

2005-01-30  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/19624

	* Makefile.in (tree-ssa-pre.o): Add CFGLOOP_H.
	* tree-ssa-pre.c: Add cfgloop.h.
	Update comment.
	(pre_stats): New member, constified.
	(inserted_exprs): New static variable.
	(NECESSARY): New macro.
	(create_expression_by_pieces): Fold the expression, and
	mark it as defaulting to not necessary. Also put in
	inserted_exprs.
	(fully_constant_expression): New function.
	(insert_into_preds_of_block): Modify to not insert phis when we
	are playing with induction variables.
	Push phis onto the inserted_exprs vector, and mark them as not
	necessary by default.
	(insert_aux): Call fully_constant_expression on eprime.
	If all edges produce the same value, mark it constant.
	(mark_operand_necessary): New function.
	(remove_dead_inserted_code): New function.
	(init_pre): Init loop optimizer to get loop info.
	(fini_pre): Free loop_optimizer, and inserted_exprs vec.
	(execute_pre): Commit edge inserts, then remove dead code.

From-SVN: r94448
parent 61e067cc
...@@ -1663,7 +1663,7 @@ tree-ssa-copyrename.o : tree-ssa-copyrename.c $(TREE_FLOW_H) $(CONFIG_H) \ ...@@ -1663,7 +1663,7 @@ tree-ssa-copyrename.o : tree-ssa-copyrename.c $(TREE_FLOW_H) $(CONFIG_H) \
tree-ssa-pre.o : tree-ssa-pre.c $(TREE_FLOW_H) $(CONFIG_H) \ tree-ssa-pre.o : tree-ssa-pre.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(TREE_H) $(TM_P_H) $(EXPR_H) \ $(SYSTEM_H) $(TREE_H) $(TM_P_H) $(EXPR_H) \
$(GGC_H) output.h diagnostic.h errors.h toplev.h $(TIMEVAR_H) \ $(GGC_H) output.h diagnostic.h errors.h toplev.h $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) $(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) $(CFGLOOP_H)
tree-vn.o : tree-vn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GGC_H) \ tree-vn.o : tree-vn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GGC_H) \
$(TREE_H) $(TREE_FLOW_H) $(HASHTAB_H) langhooks.h tree-pass.h \ $(TREE_H) $(TREE_FLOW_H) $(HASHTAB_H) langhooks.h tree-pass.h \
$(TREE_DUMP_H) diagnostic.h $(TREE_DUMP_H) diagnostic.h
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
int main(void)
{
int x, c, y;
x = 3;
if (c)
x = 2;
y = x + 1;
return y;
}
/* We should eliminate the x+1 computation from this routine, replacing
it with a phi of 3, 4 */
/* { dg-final { scan-tree-dump-times "Eliminated:1" 1 "pre"} } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
int
foo (int i)
{
int a, b;
if (i)
a = 3, b = 2;
else
a = 2, b = 3;
return a + b;
}
/* We should detect that a+b is the same along both edges, and replace it with
5 */
/* { dg-final { scan-tree-dump-times "Constified:1" 1 "pre"} } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
int main(int x)
{
int c, y;
if (c)
x = 2;
y = x + 1;
return y;
}
/* We should eliminate one evaluation of x + 1 along the x = 2 path,
causing one elimination. */
/* { dg-final { scan-tree-dump-times "Eliminated:1" 1 "pre"} } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment