I am surprised that we didn't do this already.
While it would be good to not introduce one more SROA invocation,
but instead move the one from PassBuilder::buildFunctionSimplificationPipeline(),
the existing test coverage says that is a bad idea,
though it would be fine compile-time wise: https://llvm-compile-time-tracker.com/compare.php?from=b150d34c47efbd8fa09604bce805c0920360f8d7&to=5a9a5c855158b482552be8c7af3e73d67fa44805&stat=instructions
So instead, i add yet another SROA run.
I have checked, and it needs to be at least after said full loop unrolling,
but i suppose placing it after InstCombine does not hurt.
Surprisingly, this is still fine compile-time wise: https://llvm-compile-time-tracker.com/compare.php?from=70324cd88328c0924e605fa81b696572560aa5c9&to=fb489bbef687ad821c3173a931709f9cad9aee8a&stat=instructions
Now, something in that link makes me cringe.
Compare it with https://llvm-compile-time-tracker.com/compare.php?from=70324cd88328c0924e605fa81b696572560aa5c9&to=d534377c0324a63ac26b990967577562e28a148f&stat=instructions
Those two commits share base, and don't functionally differ,
yet that +0.23% 'regression' is there in one of them.
I've encountered this in a real code, SROA-after-final-loop-unrolling.ll has been reduced from https://godbolt.org/z/fsdMhETh3
Is there a reason to put this down here vs. tacking it on the end of the previous IsFullLTO block?
If LoopUnroll is the reason for adding SROA, then mention that specifically in the comment?
IIRC, all of the FullLTO predicates in this set of passes were questionable (see TODO comment above this function). They just accumulated because the code was duplicated and diverged over time.