[LLVMdev] Rematerialization and spilling

Andrew Trick atrick at apple.com
Mon Jun 3 10:25:03 PDT 2013


On Jun 3, 2013, at 9:50 AM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:

> 
> On Jun 3, 2013, at 9:42 AM, Steve Montgomery <stephen.montgomery3 at btinternet.com> wrote:
> 
>> Hi Jakob,
>> 
>> thanks for the advice. I'll do as you suggest and make sure that CCR is never live.
>> 
>> I can use pseudo-instructions to bundle cmp+jump but it's not ideal because I might also have to bundle cmp+jump+jump+... into a pseudo. Also, there are several flavours of cmp instruction so I might need a lot of pseudos.
>> 
>> That's what led me to wonder whether MachineInstrBundles might be a neater solution but I wasn't sure whether they were really intended, or suitable, for this purpose.
> 
> That might be possible, at least the register allocator understands bundles.
> 
> Passes before register allocation are not bundle aware, including the MI scheduler. You may be able to form the bundles with some kind of MI scheduler plug-in.

The MI scheduler pass is the place to do the bundling. Exposing bundles to earlier passes could be tricky.

If you’re not actually using MI, you can define your own pass instead and substitute it using TargetPassConfig::substititePass.

You can keep LiveIntervals up-to-date to avoid recomputing them. If you’re just moving instructions around, and no vregs will be live into the middle of a bundle (e.g only bundling cmp+jmp), then LIS->handleMove() should hopefully fix it. If you ever bundle something with live vregs into the middle of a bundle, you probably need handeMoveIntoBundle(). I’ve been wanting a better API for this, but it’s hard to develop without many in-tree users.

For those who want to reuse parts of the existing MachineScheduler, there are many places to plug in. MachineSchedRegistry provides the hook. At that point you can define your own ScheduleDAGInstrs or ScheduleDAGMI subclass. People who only want to define new heuristics should reuse ScheduleDAGMI directly and only define their own MachineSchedStrategy. It may be possible to bundle within MachineSchedStrategy::schedNode, but it would be easy to mess up ScheduleDAGMI’s iterators in the process.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130603/3506481c/attachment.html>


More information about the llvm-dev mailing list