Commit 18d08014 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/15353 ([tree-ssa] Merge two "if"s if one subsumes the other.)

2007-06-12  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/15353
	PR tree-optimization/31657
	* passes.c (init_optimization_passes): Add pass_tree_ifcombine.
	* timevar.def: Add TV_TREE_IFCOMBINE.
	* tree-pass.h (pass_tree_ifcombine): Declare.
	* tree-ssa-ifcombine.c: New file.
	* tree-ssa-phiopt.c (blocks_in_phiopt_order): Export.
	* tree-flow.h (blocks_in_phiopt_order): Declare.
	* Makefile.in (OBJS-common): Add tree-ssa-ifcombine.o.
	(tree-ssa-ifcombine.o): New dependencies.

	* gcc.c-torture/execute/20070424-1.c: New testcase.
	* gcc.dg/tree-ssa/ssa-ifcombine-1.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-2.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-3.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-4.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ifcombine-5.c: Likewise.

From-SVN: r125644
parent 7f482dfe
2007-06-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/15353
PR tree-optimization/31657
* passes.c (init_optimization_passes): Add pass_tree_ifcombine.
* timevar.def: Add TV_TREE_IFCOMBINE.
* tree-pass.h (pass_tree_ifcombine): Declare.
* tree-ssa-ifcombine.c: New file.
* tree-ssa-phiopt.c (blocks_in_phiopt_order): Export.
* tree-flow.h (blocks_in_phiopt_order): Declare.
* Makefile.in (OBJS-common): Add tree-ssa-ifcombine.o.
(tree-ssa-ifcombine.o): New dependencies.
2007-06-12 Uros Bizjak <ubizjak@gmail.com> 2007-06-12 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/32293 PR rtl-optimization/32293
......
...@@ -1119,6 +1119,7 @@ OBJS-common = \ ...@@ -1119,6 +1119,7 @@ OBJS-common = \
tree-ssa-dom.o \ tree-ssa-dom.o \
tree-ssa-dse.o \ tree-ssa-dse.o \
tree-ssa-forwprop.o \ tree-ssa-forwprop.o \
tree-ssa-ifcombine.o \
tree-ssa-live.o \ tree-ssa-live.o \
tree-ssa-loop-ch.o \ tree-ssa-loop-ch.o \
tree-ssa-loop-im.o \ tree-ssa-loop-im.o \
...@@ -1942,6 +1943,9 @@ tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ ...@@ -1942,6 +1943,9 @@ tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \ $(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \ $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
langhooks.h $(FLAGS_H) langhooks.h $(FLAGS_H)
tree-ssa-ifcombine.o : tree-ssa-ifcombine.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TM_H) $(TREE_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) $(DIAGNOSTIC_H) $(TIMEVAR_H)
tree-ssa-phiopt.o : tree-ssa-phiopt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ tree-ssa-phiopt.o : tree-ssa-phiopt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \ $(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) langhooks.h $(FLAGS_H) \ $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) langhooks.h $(FLAGS_H) \
......
...@@ -575,6 +575,7 @@ init_optimization_passes (void) ...@@ -575,6 +575,7 @@ init_optimization_passes (void)
opportunities. */ opportunities. */
NEXT_PASS (pass_phi_only_cprop); NEXT_PASS (pass_phi_only_cprop);
NEXT_PASS (pass_tree_ifcombine);
NEXT_PASS (pass_phiopt); NEXT_PASS (pass_phiopt);
NEXT_PASS (pass_may_alias); NEXT_PASS (pass_may_alias);
NEXT_PASS (pass_tail_recursion); NEXT_PASS (pass_tail_recursion);
......
2007-06-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/15353
PR tree-optimization/31657
* gcc.c-torture/execute/20070424-1.c: New testcase.
* gcc.dg/tree-ssa/ssa-ifcombine-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-4.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-5.c: Likewise.
2007-06-12 Uros Bizjak <ubizjak@gmail.com> 2007-06-12 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/32293 PR rtl-optimization/32293
extern void abort (void);
extern void exit (int);
void do_exit (void) { exit (0); }
void do_abort (void) { abort (); }
void foo (int x, int a)
{
if (x < a)
goto doit;
do_exit ();
if (x != a)
goto doit;
/* else */
do_abort ();
return;
doit:
do_abort ();
}
int main()
{
foo (1, 0);
return 0;
}
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
/* Testcase for PR31657. */
int foo (int x, int a, int b)
{
int c = 1 << a;
if (x & c)
if (x & (1 << b))
/* returning 1 causes phiopt to trigger in */
return 2;
return 0;
}
/* { dg-final { scan-tree-dump "\\|" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
/* Testcase for PR31657. */
int foo (int x, int a, int b)
{
/* if ((x & a) || (x & b)) */
if (x & a)
goto doit;
if (x & b)
goto doit;
/* else */
return 0;
/* then - returing 1 causes phiopt to trigger */
doit:
return 2;
}
/* { dg-final { scan-tree-dump "\\|" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
/* Testcase extracted from PR15353. */
int foo (int x, int a)
{
/* if ((x > a) || (x == a)) */
if (x > a)
goto doit;
if (x == a)
goto doit;
/* else */
return 0;
/* then - returing 1 causes phiopt to trigger */
doit:
return 2;
}
/* { dg-final { scan-tree-dump ">=" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
/* Testcase extracted from PR15353. */
extern void bar(void);
void foo (int x, int a)
{
/* if ((x < a) || (x != a)) return; else bar (); */
if (x < a)
return;
if (x != a)
return;
/* else */
bar ();
}
/* { dg-final { scan-tree-dump "!=" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
/* Testcase from PR15353. */
int g(void);
int h(void);
int f(int *i, int *j)
{
while (1)
{
if (*i > *j || *i == *j)
break;
return g();
}
return h();
}
/* { dg-final { scan-tree-dump ">=" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -187,6 +187,7 @@ DEFTIMEVAR (TV_REG_STACK , "reg stack") ...@@ -187,6 +187,7 @@ DEFTIMEVAR (TV_REG_STACK , "reg stack")
DEFTIMEVAR (TV_FINAL , "final") DEFTIMEVAR (TV_FINAL , "final")
DEFTIMEVAR (TV_SYMOUT , "symout") DEFTIMEVAR (TV_SYMOUT , "symout")
DEFTIMEVAR (TV_VAR_TRACKING , "variable tracking") DEFTIMEVAR (TV_VAR_TRACKING , "variable tracking")
DEFTIMEVAR (TV_TREE_IFCOMBINE , "tree if-combine")
/* Everything else in rest_of_compilation not included above. */ /* Everything else in rest_of_compilation not included above. */
DEFTIMEVAR (TV_REST_OF_COMPILATION , "rest of compilation") DEFTIMEVAR (TV_REST_OF_COMPILATION , "rest of compilation")
...@@ -962,6 +962,7 @@ extern tree get_vectype_for_scalar_type (tree); ...@@ -962,6 +962,7 @@ extern tree get_vectype_for_scalar_type (tree);
/* In tree-ssa-phiopt.c */ /* In tree-ssa-phiopt.c */
bool empty_block_p (basic_block); bool empty_block_p (basic_block);
basic_block *blocks_in_phiopt_order (void);
/* In tree-ssa-loop*.c */ /* In tree-ssa-loop*.c */
......
...@@ -298,6 +298,7 @@ extern struct tree_opt_pass pass_warn_function_noreturn; ...@@ -298,6 +298,7 @@ extern struct tree_opt_pass pass_warn_function_noreturn;
extern struct tree_opt_pass pass_phiopt; extern struct tree_opt_pass pass_phiopt;
extern struct tree_opt_pass pass_forwprop; extern struct tree_opt_pass pass_forwprop;
extern struct tree_opt_pass pass_phiprop; extern struct tree_opt_pass pass_phiprop;
extern struct tree_opt_pass pass_tree_ifcombine;
extern struct tree_opt_pass pass_dse; extern struct tree_opt_pass pass_dse;
extern struct tree_opt_pass pass_nrv; extern struct tree_opt_pass pass_nrv;
extern struct tree_opt_pass pass_mark_used_blocks; extern struct tree_opt_pass pass_mark_used_blocks;
......
...@@ -45,7 +45,6 @@ static bool minmax_replacement (basic_block, basic_block, ...@@ -45,7 +45,6 @@ static bool minmax_replacement (basic_block, basic_block,
static bool abs_replacement (basic_block, basic_block, static bool abs_replacement (basic_block, basic_block,
edge, edge, tree, tree, tree); edge, edge, tree, tree, tree);
static void replace_phi_edge_with_variable (basic_block, edge, tree, tree); static void replace_phi_edge_with_variable (basic_block, edge, tree, tree);
static basic_block *blocks_in_phiopt_order (void);
/* This pass tries to replaces an if-then-else block with an /* This pass tries to replaces an if-then-else block with an
assignment. We have four kinds of transformations. Some of these assignment. We have four kinds of transformations. Some of these
...@@ -247,7 +246,7 @@ tree_ssa_phiopt (void) ...@@ -247,7 +246,7 @@ tree_ssa_phiopt (void)
that if a block X has just a single predecessor Y, then Y is after X in the that if a block X has just a single predecessor Y, then Y is after X in the
ordering. */ ordering. */
static basic_block * basic_block *
blocks_in_phiopt_order (void) blocks_in_phiopt_order (void)
{ {
basic_block x, y; basic_block x, y;
......
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