Commit b6e99746 by Martin Jambor Committed by Martin Jambor

Makefile.in (tree-switch-conversion.o): Add.

2008-07-01  Martin Jambor  <mjambor@suse.cz>
        * Makefile.in (tree-switch-conversion.o): Add.
        (OBJS-common): Add tree-swtch-conversion.o.
        * passes.c (init_optimization_passes): Add pass_convert_switch.
        * tree-pass.h: (pass_convert_switch): Add.
        * tree-switch-conversion.c: New file.
        * gcc.dg/tree-ssa/cswtch.c: New testcase.
        * common.opt (ftree-cswtch): New option.
        * params.h (PARAM_SWITCH_CONVERSION_BRANCH_RATIO): New parameter.
        * params.def (PARAM_SWITCH_CONVERSION_BRANCH_RATIO): New parameter.
        * opts.c (decode_options): Set flag_tree_switch_conversion when
        optimization level is >= 2.
        * doc/invoke.texi (Optimize Options): Added description of
        -ftree-swtch-conversion and switch-conversion-max-branch-ratio.

From-SVN: r137313
parent ab652c72
2008-07-01 Martin Jambor <mjambor@suse.cz>
* Makefile.in (tree-switch-conversion.o): Add.
(OBJS-common): Add tree-swtch-conversion.o.
* passes.c (init_optimization_passes): Add pass_convert_switch.
* tree-pass.h: (pass_convert_switch): Add.
* tree-switch-conversion.c: New file.
* gcc.dg/tree-ssa/cswtch.c: New testcase.
* common.opt (ftree-cswtch): New option.
* params.h (PARAM_SWITCH_CONVERSION_BRANCH_RATIO): New parameter.
* params.def (PARAM_SWITCH_CONVERSION_BRANCH_RATIO): New parameter.
* opts.c (decode_options): Set flag_tree_switch_conversion when
optimization level is >= 2.
* doc/invoke.texi (Optimize Options): Added description of
-ftree-swtch-conversion and switch-conversion-max-branch-ratio.
2008-06-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* config/darwin-driver.c (darwin_default_min_version): Fix
......
......@@ -1176,6 +1176,7 @@ OBJS-common = \
tree-profile.o \
tree-scalar-evolution.o \
tree-sra.o \
tree-switch-conversion.o \
tree-ssa-address.o \
tree-ssa-alias.o \
tree-ssa-alias-warnings.o \
......@@ -2629,6 +2630,11 @@ tree-sra.o : tree-sra.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) \
$(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_GIMPLE_H) \
langhooks.h tree-pass.h $(FLAGS_H) $(EXPR_H) $(BASIC_BLOCK_H) \
bitmap.h $(GGC_H) hard-reg-set.h $(OBSTACK_H) $(PARAMS_H) $(TARGET_H)
tree-switch-conversion.o : tree-switch-conversion.c $(CONFIG_H) $(SYSTEM_H) \
$(TREE_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TREE_INLINE_H) \
$(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_GIMPLE_H) \
tree-pass.h $(FLAGS_H) $(EXPR_H) $(BASIC_BLOCK_H) output.h \
$(GGC_H) $(OBSTACK_H) $(PARAMS_H) $(CPPLIB_H) $(PARAMS_H)
tree-complex.o : tree-complex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
$(TM_H) $(RTL_H) $(REAL_H) $(FLAGS_H) $(TREE_FLOW_H) $(TREE_GIMPLE_H) \
tree-iterator.h tree-pass.h tree-ssa-propagate.h $(DIAGNOSTIC_H)
......
......@@ -1088,6 +1088,10 @@ ftree-cselim
Common Report Var(flag_tree_cselim) Init(2) Optimization
Transform condition stores into unconditional ones
ftree-switch-conversion
Common Report Var(flag_tree_switch_conversion) Optimization
Perform conversions of switch initializations.
ftree-dce
Common Report Var(flag_tree_dce) Optimization
Enable SSA dead code elimination optimization on trees
......
......@@ -359,10 +359,10 @@ Objective-C and Objective-C++ Dialects}.
-ftree-loop-distribution @gol
-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-reassoc @gol
-ftree-sink -ftree-sra -ftree-store-ccp -ftree-ter @gol
-ftree-vect-loop-version -ftree-vectorize -ftree-vrp -funit-at-a-time @gol
-funroll-all-loops -funroll-loops -funsafe-loop-optimizations @gol
-funsafe-math-optimizations -funswitch-loops @gol
-ftree-sink -ftree-sra -ftree-store-ccp -ftree-switch-conversion @gol
-ftree-ter -ftree-vect-loop-version -ftree-vectorize -ftree-vrp @gol
-funit-at-a-time -funroll-all-loops -funroll-loops @gol
-funsafe-loop-optimizations -funsafe-math-optimizations -funswitch-loops @gol
-fvariable-expansion-in-unroller -fvect-cost-model -fvpt -fweb @gol
-fwhole-program @gol
--param @var{name}=@var{value}
......@@ -5194,6 +5194,7 @@ also turns on the following optimization flags:
-fsched-interblock -fsched-spec @gol
-fschedule-insns -fschedule-insns2 @gol
-fstrict-aliasing -fstrict-overflow @gol
-ftree-switch-conversion @gol
-ftree-pre @gol
-ftree-vrp}
......@@ -5868,6 +5869,11 @@ pass operates on both local scalar variables and memory stores and
loads (global variables, structures, arrays, etc). This flag is
enabled by default at @option{-O2} and higher.
@item -ftree-switch-conversion
Perform conversion of simple initializations in a switch to
initializations from a scalar array. This flag is enabled by default
at @option{-O2} and higher.
@item -ftree-dce
@opindex ftree-dce
Perform dead code elimination (DCE) on trees. This flag is enabled by
......@@ -7344,6 +7350,11 @@ mechanism for comparing types in C++ and Objective-C++. However, if
bugs in the canonical type system are causing compilation failures,
set this value to 0 to disable canonical types.
@item switch-conversion-max-branch-ratio
Switch initialization conversion will refuse to create arrays that are
bigger than @option{cswtch-max-branch-ratio} times the number of
branches in the switch.
@item max-partial-antic-length
Maximum length of the partial antic set computed during the tree
partial redundancy elimination optimization (@option{-ftree-pre}) when
......
......@@ -891,6 +891,7 @@ decode_options (unsigned int argc, const char **argv)
flag_reorder_functions = 1;
flag_tree_store_ccp = 1;
flag_tree_vrp = 1;
flag_tree_switch_conversion = 1;
if (!optimize_size)
{
......
......@@ -710,6 +710,15 @@ DEFPARAM (PARAM_DF_DOUBLE_QUEUE_THRESHOLD_FACTOR,
"Multiplier used for determining the double-queueing threshold",
2, 0, 0)
/* Switch initialization conversion will refuse to create arrays that are
bigger than this parameter times the number of switch branches. */
DEFPARAM (PARAM_SWITCH_CONVERSION_BRANCH_RATIO,
"switch-conversion-max-branch-ratio",
"The maximum ratio between array size and switch branches for "
"a switch conversion to take place",
8, 1, 0)
/*
Local variables:
mode:c
......
......@@ -167,4 +167,6 @@ typedef enum compiler_param
PARAM_VALUE (PARAM_L2_CACHE_SIZE)
#define USE_CANONICAL_TYPES \
PARAM_VALUE (PARAM_USE_CANONICAL_TYPES)
#define SWITCH_CONVERSION_BRANCH_RATIO \
PARAM_VALUE (PARAM_SWITCH_CONVERSION_BRANCH_RATIO)
#endif /* ! GCC_PARAMS_H */
......@@ -572,6 +572,7 @@ init_optimization_passes (void)
NEXT_PASS (pass_update_address_taken);
NEXT_PASS (pass_simple_dse);
NEXT_PASS (pass_tail_recursion);
NEXT_PASS (pass_convert_switch);
NEXT_PASS (pass_profile);
NEXT_PASS (pass_release_ssa_names);
}
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-switchconv" } */
/* { dg-do run } */
extern void abort (void);
static int X, Y;
int check(int param)
{
int a = 0;
int b = 1;
switch (param)
{
case -2:
a = 0;
b = -1;
break;
case 1:
case 2:
a = 8;
b = 6;
break;
case 3:
a = 9;
b = 5;
break;
case 6:
a = 10;
b = 4;
break;
default:
a = 16;
b = 1;
}
X = a;
Y = b;
return 0;
}
void assertions(int a, int b)
{
if (X != a || Y != b)
abort();
return;
}
int main ()
{
check (-10);
assertions (16, 1);
check (-2);
assertions (0, -1);
check(1);
assertions (8, 6);
check(2);
assertions (8, 6);
check(3);
assertions (9, 5);
check(5);
assertions (16, 1);
check(6);
assertions (10, 4);
check(12);
assertions (16, 1);
return 0;
}
/* { dg-final { scan-tree-dump "Switch converted" "switchconv" } } */
/* { dg-final { cleanup-tree-dump "switchconv" } } */
......@@ -508,6 +508,7 @@ extern struct gimple_opt_pass pass_O0_always_inline;
extern struct gimple_opt_pass pass_inline_parameters;
extern struct gimple_opt_pass pass_all_early_optimizations;
extern struct gimple_opt_pass pass_update_address_taken;
extern struct gimple_opt_pass pass_convert_switch;
/* The root of the compilation pass tree, once constructed. */
extern struct opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes;
......
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