]> git.ipfire.org Git - people/ms/gcc.git/commit
unswitching of outer loops
authorRichard Biener <rguenther@suse.de>
Tue, 27 Sep 2022 08:16:52 +0000 (10:16 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 10 Nov 2022 10:53:13 +0000 (11:53 +0100)
commit9e11ceef165bc074c2fc85b8ddece606b24e710b
tree165a86411910d5ec0d49a13f7b0ea6a0a977f73b
parent49de156a6adb50e0624479f22c20141cadef812d
unswitching of outer loops

This allows loop unswitching to unswitch outer loops conditions are
invariant in.  We restrict ourselves to unswitch conditions in innermost
loops and will only unswitch loop nests that do not contain any sibling loops.
To simplify the implementation the loop nest unswitched is the deepest all
unswitching candidates are invariant in.

For 507.cactuBSSN_r it can be observed we unswitch the outer loops
of the compute kernels for the fdOrder parameter.  It seems to be within
the existing growth limitations to perform the unswitchings, a performance
benefit is not seen.

* tree-ssa-loop-unswitch.cc (init_loop_unswitch_info): First collect
candidates and determine the outermost loop to unswitch.
(tree_ssa_unswitch_loops): First perform all guard hoisting,
then perform unswitching on innermost loop predicates.
(find_unswitching_predicates_for_bb): Keep track of the
outermost loop to unswitch.
(evaluate_bbs): Adjust exit test.
(tree_unswitch_single_loop): Dump whether we unswitched an outer
loop.
(tree_unswitch_loop): Remove assert we unswitch only innermost
loops.

* gcc.dg/loop-unswitch-18.c: New testcase.
* gcc.dg/tree-ssa/loopclosedphi.c: Disable unswitching,
adjust expected counts.
* gcc.dg/torture/pr71462.c: Add -w to ignore undefined
behavior diagnostics after now unswitching outer loops.
gcc/testsuite/gcc.dg/loop-unswitch-18.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr71462.c
gcc/testsuite/gcc.dg/tree-ssa/loopclosedphi.c
gcc/tree-ssa-loop-unswitch.cc