[llvm-dev] Make MachineLICM PostRA (or PreRa) work only on the inner loop for a loop nest

Alex Susu via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 24 04:56:56 PST 2017


   Hello.
     I found a solution to this problem I asked about - make MachineLICM pre-RA (or 
post-RA, in principle) work only on the inner loop for a loop nest. Basically, I had to 
change the code of MachineLICM.cpp, by adding in method
       MachineLICM::HoistOutOfLoop(MachineDomTreeNode *HeaderN)
     in the loop:
       for (MachineDomTreeNode *Node : Scopes) {
         MachineBasicBlock *MBB = Node->getBlock();
         ...
       }
   some extra code that checks if MBB has name "vector.body", which is the inner loop that 
I care about, and in such case I set Preheader variable defined there to be the 
predecessor of vector.body, normally called "vector.ph".
     If you want I can provide the exact code patch.

     Since these are the only cases I care about, namely loops (or loop nests) resulted 
from the LoopVectorize LLVM module, this small patch serves well.

     So, I could not employ the command-line arguments of llc and had to adapt the code of 
the MachineLICM pass.

   Best regards,
     Alex


On 2/22/2017 9:05 AM, Alex Susu wrote:
>   Hello.
>     I am curious if I can make the MachineLICM transformation work only on the inner loop
> when it encounters a loop nest in the program.
>
>     I've started examining the source code of the pass -
> http://llvm.org/docs/doxygen/html/MachineLICM_8cpp_source.html . I found comments like
> <<// If this is done before regalloc, only visit outer-most preheader-sporting // loops>>.
>     I'll come back if I find a solution.
>
>   Thank you very much,
>     Alex
>
>
>


More information about the llvm-dev mailing list