[llvm] [LoopUnroll] Structural cost savings analysis for full loop unrolling (PR #114579)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 07:39:53 PST 2024
nikic wrote:
This seems conceptually similar to something I tried a while ago (I have an old patch stub here: https://github.com/llvm/llvm-project/commit/26df05e27ce6c6742c6f523c926f4874ff5ca3ef). The problem I ran into, and why I didn't end up pursuing this further, was that if we more accurately model full unrolling cost, we end up unrolling more (duh) and from inspecting IR diffs the additional unrolls weren't always profitable. If we make cost modelling more accurate, we may have to reduce unrolling thresholds to compensate.
The other thing to watch out for, especially for your motivating example, is catastrophic unrolling. If you have this kind of nested loop and unroll the outer loop first, you can get quadratic unrolling. See https://github.com/llvm/llvm-project/issues/57865 for an example where simple input IR results in massive output IR that hangs the compiler and https://github.com/llvm/llvm-project/pull/67137 for a related patch. If I understand correctly, your patch is going to make this problem worse than it is right now, because now there will be an additional bonus to unrolling the outer loop.
https://github.com/llvm/llvm-project/pull/114579
More information about the llvm-commits
mailing list