[all-commits] [llvm/llvm-project] 48ecba: [MachineLICM][MachineSink] Move SinkIntoLoop to Ma...
sjoerdmeijer via All-commits
all-commits at lists.llvm.org
Wed Jan 27 02:53:40 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 48ecba350ed6477ae194720b263eff194bf0271c
https://github.com/llvm/llvm-project/commit/48ecba350ed6477ae194720b263eff194bf0271c
Author: Sjoerd Meijer <sjoerd.meijer at arm.com>
Date: 2021-01-27 (Wed, 27 Jan 2021)
Changed paths:
M llvm/lib/CodeGen/MachineLICM.cpp
M llvm/lib/CodeGen/MachineSink.cpp
A llvm/test/CodeGen/AArch64/loop-sink.mir
R llvm/test/CodeGen/X86/sink-cheap-instructions.ll
R llvm/test/DebugInfo/MIR/X86/mlicm-sink.mir
Log Message:
-----------
[MachineLICM][MachineSink] Move SinkIntoLoop to MachineSink.
This moves SinkIntoLoop from MachineLICM to MachineSink. The motivation for
this work is that hoisting is a canonicalisation transformation, but we do not
really have a good story to sink instructions back if that is better, e.g. to
reduce live-ranges, register pressure and spilling. This has been discussed a
few times on the list, the latest thread is:
https://lists.llvm.org/pipermail/llvm-dev/2020-December/147184.html
There it was pointed out that we have the LoopSink IR pass, but that works on
IR, lacks register pressure informatiom, and is focused on profile guided
optimisations, and then we have MachineLICM and MachineSink that both perform
sinking. MachineLICM is more about hoisting and CSE'ing of hoisted
instructions. It also contained a very incomplete and disabled-by-default
SinkIntoLoop feature, which we now move to MachineSink.
Getting loop-sinking to do something useful is going to be at least a 3-step
approach:
1) This is just moving the code and is almost a NFC, but contains a bug fix.
This uses helper function `isLoopInvariant` that was factored out in D94082 and
added to MachineLoop.
2) A first functional change to make loop-sink a little bit less restrictive,
which it really is at the moment, is the change in D94308. This lets it do
more (alias) analysis using functions in MachineSink, making it a bit more
powerful. Nothing changes much: still off by default. But it shows that
MachineSink is a better home for this, and it starts using its functionality
like `hasStoreBetween`, and in the next step we can use `isProfitableToSinkTo`.
3) This is the going to be he interesting step: decision making when and how
many instructions to sink. This will be driven by the register pressure, and
deciding if reducing live-ranges and loop sinking will help in better
performance.
4) Once we are happy with 3), this should be enabled by default, that should be
the end goal of this exercise.
Differential Revision: https://reviews.llvm.org/D93694
More information about the All-commits
mailing list