[llvm] [RISCV][VLOPT] Don't reduce the VL is the same as CommonVL (PR #123878)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 23:05:13 PST 2025
topperc wrote:
> > I don't think this is an infinite loop, but a pathologically slow case where the chain of instructions is really long. But pruning the worklist when the CommonVL is the same seems like a sensible way to manage it.
>
> If so, I think we should add a list of handled instructions to remove duplicated instructions in:
>
> https://github.com/llvm/llvm-project/blob/ebb27ccb08e0579825a53b218ff5b2ddc492626a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp#L1341-L1355
>
>
> Just like:
> https://github.com/llvm/llvm-project/blob/ebb27ccb08e0579825a53b218ff5b2ddc492626a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp#L15777-L15799
The problem is that we visit every instruction in the basic block in the outer loop. And we visit every earlier instruction anytime we make a change using a worklist. So the problem is that we process most of the graph using the worklist, but then the outer loop still causes us to revisit everything again. Each time we run through the worklist all over again.
What we should probably do is pre-load the worklist with the entire basic block instead of using the outer loop. The worklist is a SetVector so won't add anything more than once.
https://github.com/llvm/llvm-project/pull/123878
More information about the llvm-commits
mailing list