[llvm-dev] [RFC] Register Rematerialization (remat) Extension

Andrew Trick via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 12 10:14:07 PDT 2016


> On Sep 12, 2016, at 8:51 AM, vivek pandya via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> 
> 1 ) As LLVM MI is already in SSA form before reg allocation so for LLVM I think it does not require to build SSA graph and converting it back after optimization completed as mentioned in [1]
> 
> 2 ) We would like to add a pass similar to SCCP.cpp (Sparse Conditional Constant
> Propagation based on Wegman and Zadeck's work http://dl.acm.org/citation.cfm?id=103136 <http://dl.acm.org/citation.cfm?id=103136>) as desribed in [1]. This pass will be scheduled to run before register allocation.
> 
> 3 ) Output of the pass added in Step 2 will be a Map of def to instructions pointers (instructions which can be used to remat the given live range). The map will contain live ranges which is due to single instruction and multiple instructions.

LiveIntervals maintains a quasi-SSA form via VNInfo. It does not allow efficient def-use queries, but use-def is there, which is all that you should need.

It would be great to have better remat during regalloc, but please try to avoid building additional state that needs to be maintained.

-Andy

> 
> 4 ) The remat APIs defined in LiveRangeEdit.cpp will use analysis from the Map
> when a spill is required for RA.
> 
> 5 ) The remat transformation APIs like rematerializeAt() will be teached to remat
> live ranges with multiple instructions too.
> 
> 6 ) A cost analysis will be require to decide between remat and spill. This should be based on at least two factors register pressure and spill cost
> 
> Few points:
> --------------
> * The analysis pass to be addes as per (2) will use target specific information
> from TargetInstrInfo.cpp as the current remat infrastructure uses.
> 
> * This approach will not be on demand as the current approach is (i.e remat specific
> code will be executed only if there is a spill) so the pass in (2) can be an
> overhead so we may want it to enable only for higher level of optimization.
> 
> * Will it be possible to use existing SCCP.cpp code with few modification to lattice
> and related mathematical operation so that it can serve both purpose?
> 
> * No changes in current register allocators or spill framework will be required
> because remat entry point will be LiveRangeEdit.
> 
> Any other way with less overhead is always welcomed.
> Please help us developing a plan to implement this.
> 
> Hoping for comments!
> 
> Sincerely,
> Vivek
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

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


More information about the llvm-dev mailing list