Hi, I have some constants that get loaded into a register, and then the register is copied to another register, and then used. I suspect this stems from PHI nodes lowering.I cannot avoid this right now, as the MI PHI's will only hold registers, and not constants. Therefore this gets complicated, having to handle the introduced copies from the Eliminate PHIs pass, while the IR is not on SSA-form anymore. Is there a simple way to handle this that I have missed? Thanks, Jonas -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110224/39de771b/attachment.html>
Jakob Stoklund Olesen
2011-Feb-25 00:47 UTC
[LLVMdev] Loading of immediates into registers
On Feb 24, 2011, at 4:24 AM, Jonas Paulsson wrote:> I have some constants that get loaded into a register, and then the register is copied to another register, and then used. I suspect this stems from PHI nodes lowering.I cannot avoid this right now, as the MI PHI's will only hold registers, and not constants. Therefore this gets complicated, having to handle the introduced copies from the Eliminate PHIs pass, while the IR is not on SSA-form anymore. > > Is there a simple way to handle this that I have missed?It depends on what you mean by 'loaded'. If you have a cheap instruction that puts an immediate in a register, mark it as rematerializable and 'as cheap as a move'. Then the register allocator will replace all copies with rematerialized copies of the original instruction. See MOV8ri and friends in X86InstrInfo.td. If you mean a constant pool load, copies are preferred unless the value needs to be spilled. You should mark your load instructions as rematerializable as well. /jakob
Possibly Parallel Threads
- [LLVMdev] Poor register allocation (constants causing spilling)
- [LLVMdev] rematerialization question
- [LLVMdev] Rematerialization and spilling
- Extending Register Rematerialization
- How to get Greedy RA to not spill results of trivially rematerializable instructions