[llvm-commits] [llvm] r107529 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h include/llvm/Target/Target.td include/llvm/Target/TargetOpcodes.h lib/CodeGen/LowerSubregs.cpp utils/TableGen/CodeGenTarget.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Jul 4 12:08:07 PDT 2010


On Jul 4, 2010, at 10:15 AM, Chris Lattner wrote:

> 
> On Jul 2, 2010, at 3:29 PM, Jakob Stoklund Olesen wrote:
> 
>> Author: stoklund
>> Date: Fri Jul  2 17:29:50 2010
>> New Revision: 107529
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=107529&view=rev
>> Log:
>> Add a new target independent COPY instruction and code to lower it.
>> 
>> The COPY instruction is intended to replace the target specific copy
>> instructions for virtual registers as well as the EXTRACT_SUBREG and
>> INSERT_SUBREG instructions in MachineFunctions. It won't we used in a selection
>> DAG.
>> 
>> COPY is lowered to native register copies by LowerSubregs.
> 
> Very interesting!  This means that the early code generator won't need to call the virtual method to determine if something is a copy?

Yes. I have clocked X86::isMoveInstr at around 5% CPU for both the fast register allocator and the coalescer.

There is a longer rationale here: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-June/032448.html

>  This will also make targets that forget to implement the 'is copy' hook generate better code by default.

Yes. You also get foldMemoryOperand(COPY) --> storeToStackSlot / loadFromStackSlot for free. That is the only folding PowerPC does, for instance.

I also intend to change the copyRegToReg hook to only allow physical register arguments, and eliminate the register class arguments.

> This sounds like a great plan to me.  What is the migration plan for existing targets and existing codegen passes?  Do they need to do anything?

First I am going to emit EXTRACT_SUBREG as COPY so that instruction becomes selection DAG only. This is fairly easy since both are lowered by LowerSubregs. The problem is dealing with the FIXME in SimpleRegisterCoalescing::JoinIntervals regarding physical register live intervals.

Second, INSERT_SUBREG is converted to COPY by TwoAddressInstructionPass. It is still needed while the machine code is in SSA form.

Then it is a simple issue of replacing copyRegToReg with COPY instructions, and TII::isMoveInstr() with MI->isCopy.

Existing codegen passes need to use isCopy() instead of isExtractSubreg/isInsertSubreg/isMoveInstr. I am migrating  them by first adding isCopy, and later removing the other checks.

Targets need a new copyRegToReg implementation that takes no register class arguments but requires physical registers. I will start by providing a new version that falls back to the old one, so no target changes will be necessary initially.

>  Do you think the "isMove" target hook can go away completely?

Yes, I think so. It depends on whether it is needed after LowerSubregs. A quick grep says that it isn't.

/jakob


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100704/e4699bb1/attachment.bin>


More information about the llvm-commits mailing list