From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id A968939518BB; Thu, 13 Jan 2022 16:02:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A968939518BB Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/loop-unswitch-support-switches] Add top-level comment. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/heads/devel/loop-unswitch-support-switches X-Git-Oldrev: 1fb345c4edd8bd0f5247122c9cd25f419736fc63 X-Git-Newrev: 149d1e4ec97c60610b592b945bbb6e0f19aa4355 Message-Id: <20220113160249.A968939518BB@sourceware.org> Date: Thu, 13 Jan 2022 16:02:49 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2022 16:02:49 -0000 https://gcc.gnu.org/g:149d1e4ec97c60610b592b945bbb6e0f19aa4355 commit 149d1e4ec97c60610b592b945bbb6e0f19aa4355 Author: Martin Liska Date: Thu Jan 13 17:02:38 2022 +0100 Add top-level comment. Diff: --- gcc/tree-ssa-loop-unswitch.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 1ed18154339..32c1e38c1fb 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -79,6 +79,30 @@ along with GCC; see the file COPYING3. If not see tree-ssa-loop-im.c ensures that all the suitable conditions are in this shape. */ +/* Loop unswitching algorithm for innermost loops works in the following steps: + + 1) Number of instructions is estimated for each BB that belongs to a loop. + 2) Unswitching candidates are found for gcond and gswitch statements + (note that unswitching precicate for a gswitch actually corresponds + to a non-default edge - can contain multiple cases). + 3) The so called unswitinch predicates are stored in a cache where gimple_uid + is an index to the cache. + 4) We consider one by one the unswitching candidate and calculate BBs that + will be reachable in the unswitch version. + 5) A selected predicate is chosen and we simplify CFG (dead edges) in both + versions of the loop. We utilize both Ranger for condition simplification + and also symbol equivalence. The folded if conditions are replaced with + true/false values, while for gswitch we mark the corresponding edge + with a pass-defined unreachable flag. + 6) Every time we unswitch a loop, we save unswitch_predicate to a vector + together with information if true or false edge was taken. Doing that + we have a so called PREDICATE_PATH that is utilized for simplification + of the cloned loop. + 7) The process is repeated until we reach a growth threshold or all + unswitching opportunities are taken. + +*/ + /* A tuple that holds GIMPLE condition and value range for an unswitching predicate. */