diff options
author | Martin Liska <mliska@suse.cz> | 2021-11-22 13:54:20 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-05-25 10:37:13 +0200 |
commit | a1c9f779f75283427316b5c670c1e01ff8ce9ced (patch) | |
tree | 3b23452070d3fa5c671287b3796721451c71356e /gcc/params.opt | |
parent | 0d344b557604e966dc7f91739881f03e1f221efd (diff) | |
download | gcc-a1c9f779f75283427316b5c670c1e01ff8ce9ced.zip gcc-a1c9f779f75283427316b5c670c1e01ff8ce9ced.tar.gz gcc-a1c9f779f75283427316b5c670c1e01ff8ce9ced.tar.bz2 |
Add GIMPLE switch support to loop unswitching
This patch adds support to unswitch loops with switch statements
based on invariant index. It furthermore reworks the cost model
to allow an overall budget of statements to be created per original
loop by all unswitching opportunities in the loop. Compared to
the original all unswitching opportunities in a loop are
pre-evaluated before the first transform which will allow future
changes to select the most profitable candidates first.
To efficiently support switch statements the pass now uses
ranger to simplify switch statements and conditions in loop
copies based on ranges extracted from the recorded set of
predicates unswitched.
gcc/ChangeLog:
* dbgcnt.def (DEBUG_COUNTER): Add loop_unswitch counter.
* params.opt (max-unswitch-level): Remove.
* doc/invoke.texi (max-unswitch-level): Likewise.
* tree-cfg.cc (gimple_lv_add_condition_to_bb): Support not
gimplified expressions.
* tree-ssa-loop-unswitch.cc (struct unswitch_predicate): New.
(tree_may_unswitch_on): Rename to ...
(find_unswitching_predicates_for_bb): ... this and handle
switch statements.
(get_predicates_for_bb): Likewise.
(set_predicates_for_bb): Likewise.
(init_loop_unswitch_info): Likewise.
(tree_ssa_unswitch_loops): Prepare stuff before calling
tree_unswitch_single_loop.
(tree_unswitch_single_loop): Rework the function using
pre-computed predicates and with a per original loop cost model.
(merge_last): New.
(add_predicate_to_path): Likewise.
(find_range_for_lhs): Likewise.
(simplify_using_entry_checks): Rename to ...
(evaluate_control_stmt_using_entry_checks): ... this, handle
switch statements and improve simplifications using ranger.
(simplify_loop_version): Rework using
evaluate_control_stmt_using_entry_checks.
(evaluate_bbs): New.
(evaluate_loop_insns_for_predicate): Likewise.
(tree_unswitch_loop): Adjust to allow switch statements and
pass in the edge to unswitch.
(clean_up_after_unswitching): New.
(pass_tree_unswitch::execute): Pass down fun.
gcc/testsuite/ChangeLog:
* gcc.dg/loop-unswitch-7.c: New test.
* gcc.dg/loop-unswitch-8.c: New test.
* gcc.dg/loop-unswitch-9.c: New test.
* gcc.dg/loop-unswitch-10.c: New test.
* gcc.dg/loop-unswitch-11.c: New test.
* gcc.dg/loop-unswitch-12.c: New test.
* gcc.dg/loop-unswitch-13.c: New test.
* gcc.dg/loop-unswitch-14.c: New test.
* gcc.dg/loop-unswitch-15.c: New test.
* gcc.dg/loop-unswitch-16.c: New test.
* gcc.dg/loop-unswitch-17.c: New test.
* gcc.dg/torture/20220518-1.c: New test.
* gcc.dg/torture/20220518-2.c: New test.
* gcc.dg/torture/20220525-1.c: New test.
* gcc.dg/alias-10.c: Adjust.
* gcc.dg/tree-ssa/loop-6.c: Likewise.
* gcc.dg/loop-unswitch-1.c: Likewise.
Co-authored-by: Richard Biener <rguenther@suse.de>
Diffstat (limited to 'gcc/params.opt')
-rw-r--r-- | gcc/params.opt | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/gcc/params.opt b/gcc/params.opt index b88e137..bcf1423 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -745,10 +745,6 @@ The maximum number of instructions to consider to unroll in a loop. Common Joined UInteger Var(param_max_unswitch_insns) Init(50) Param Optimization The maximum number of insns of an unswitched loop. --param=max-unswitch-level= -Common Joined UInteger Var(param_max_unswitch_level) Init(3) Param Optimization -The maximum number of unswitchings in a single loop. - -param=max-variable-expansions-in-unroller= Common Joined UInteger Var(param_max_variable_expansions) Init(1) Param Optimization If -fvariable-expansion-in-unroller is used, the maximum number of times that an individual variable will be expanded during loop unrolling. |