[llvm] [DFAJumpThreading] Avoid exploring the paths that never come back (PR #85505)

via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 16 12:09:19 PDT 2024


XChy wrote:

> > > Can you please add something like `if (VerifyLoopInfo) LI->verify(DT)` and add `-verify-loop-info` to all the DFAJumpThreading tests? Can also mark the analysis as preserved.
> > 
> > 
> > I don't think we preserve the loop analysis completely. When transforming DFA, we clone and thread BBs, which may break loop analysis. This patch only preserves it before transforming DFA, so that we get the correct result in `AllSwitchPaths::paths`.
> 
> I don't think it's a good idea to use an analysis that's not preserved. Is it possible to preserve LI through the threading optimization?
> 
> Sorry I completely missed this when looking at #85360.

I think if we don't skip over switch statement after cloning a new path, it's possible because the cloned path is in the same loop. But meanwhile, the skip have to be done in later optimizations. See also https://github.com/llvm/llvm-project/blob/c9325f8a2e7ec9bb9e0b28320aab4034bcb94a0d/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp#L1173
I'll give it a try.

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


More information about the llvm-commits mailing list