[PATCH] D87551: [LICM] Make Loop ICM profile aware again

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 20:05:21 PDT 2023


wenlei added a comment.
Herald added subscribers: pcwang-thead, StephenFan.
Herald added a project: All.

This revert falls through the cracks, but recently we saw a 3% perf regression on a very large server workload due to compiler upgrade, and we tracked it down to this revert. It triggered investigation again, and I read through the comments on patches and "LICM as canonical form" thread - thanks for following up and the clarifications @reames.

It is perhaps an extreme case that we're looking at - we have a 400+ entry cold jump table (from switch) inside a loop, and hoisting defs from each of the 400+ jump targets all to loop pre-header killed the performance. The defs from the 400+ jump table targets all feed into a PHI-use afterwards, and that PHI is what blocked loop sink.

So it comes down to PHI uses. Loop sink currently blocks sinking to PHI-use: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Scalar/LoopSink.cpp#L181-L182. I think we can see through PHI and sink to the incoming block of the value being used - I gave it a try and that seems to address our problem. Testing on a few internal components showed that removing the limitation on sinking to PHI sometimes allows 2x more loop sink to happen. I will send up a patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87551/new/

https://reviews.llvm.org/D87551



More information about the llvm-commits mailing list