[llvm] [DFAJumpThreading] Add an early exit heuristic for unpredictable values (PR #85015)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 16 07:45:21 PDT 2024


nikic wrote:

> I believe there is much space for reducing the compile-time in `AllSwitchPaths::paths`, which enumerates the paths from switch and limit the max path length to 20. If there are all conditional jumps from switch, the run time of this function can be O(n ^ 20). I will investigate into it in my free time. Hope I can improve it.

Hm, this sounds very concerning. The commonality of this patch and https://github.com/llvm/llvm-project/pull/85360 and https://github.com/llvm/llvm-project/pull/85505 is that they all just add early exits -- this is fine to reduce average impact, but it doesn't really do anything to handle degenerate cases. There will be inputs that pass them, and for them the pass will unacceptably slow (complexity n^20 is the same as an infinite loop, really). So this pass really needs more that just early exits, it needs either a different approach, or tight limits (complexity n^20 does not matter if you require n^20 < 100...)


https://github.com/llvm/llvm-project/pull/85015


More information about the llvm-commits mailing list