[LLVMdev] Instruction bundles before RA: Rematerialization

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Jun 7 11:02:05 PDT 2012


On Jun 7, 2012, at 10:25 AM, "Sergei Larin" <slarin at codeaurora.org> wrote:

> Generally as far as I concern, there is no way “generic” (platform independent) code can add instructions to bundles optimally

I agree, there are too many ways of modeling stuff with bundles. That is why I took the philosophical stance of treating bundles as black boxes during RA. I think the target should be involved whenever bundles are formed, and we shouldn't delete instructions from inside bundles without permission from the target.

I think we need to tweak some of the TargetInstrInfo hooks to make bundle remat possible. I would like your input.

Rematerialization has multiple steps:

1. Feasibility. RA knows the bundle defining a given SSA value of a virtual register. It calls TII.isTriviallyReMaterializable() to determine if the defining instruction can (and should) be rematerialized. See LiveRangeEdit::anyRematerializable().

2. Feasibility at desired location. LiveRangeEdit::canRematerializeAt() then checks that the instruction can be rematerialized at the new location. This can fail if the instruction depends on virtual register values that are not available at the new location.

3. Remat. LiveRangeEdit::rematerializeAt() calls TII.reMaterialize() (sic) to insert a copy of the defining instruction at the new location.

4. Shrink original live range. The original live range may be smaller after some uses have been rematerialized. This may discover dead defs if there are no remaining uses.

5. LiveRangeEdit::eliminateDeadDefs() erases the dead defs.

It looks like each of these steps require some help from the target if they are to handle bundles.

/jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120607/21a32e04/attachment.html>


More information about the llvm-dev mailing list