[llvm] [DFAJumpThreading] Add an early exit heuristic for unpredictable values (PR #85015)
Usman Nadeem via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 13:25:34 PDT 2024
================
@@ -439,18 +449,31 @@ struct MainSwitch {
// initial switch values that can be ignored (they will hit the
// unthreaded switch) but this assumption will get checked later after
// paths have been enumerated (in function getStateDefMap).
+
+ // If the unpredictable value comes from the same inner loop it is
+ // likely that it will also be on the enumerated paths, causing us to
+ // exit after we have enumerated all the paths. This heuristic save
+ // compile time because a search for all the paths can become expensive.
+ if (EarlyExitHeuristic && LI->getLoopFor(SI->getParent()) ==
+ LI->getLoopFor(CurrentIncomingBB)) {
----------------
UsmanNadeem wrote:
> I don't really get why this cares about the loop of the incoming BB, rather than the loop where the instruction is defined.
Also, I notice that doing so loses a couple more transformations. I haven't looked into those though.
https://github.com/llvm/llvm-project/pull/85015
More information about the llvm-commits
mailing list