[llvm-dev] Post-register allocation MachineLICM does not optimize loops

Alex Susu via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 23 06:41:29 PST 2017


   Hello.
     I want to avoid running the pre-register allocation (pre-RA) MachineLICM pass, since 
it can "destroy" some sequences of instructions that should be bundled together (and it 
seems LLVM, by design, does NOT allow to bundle MachineInstr instructions before the 
pre-RA MachineLICM pass).
     So I disabled the pre-RA LICM by always giving llc -disable-machine-licm.

     I've also applied all possible passes subarguments for the post-register allocation 
(post-RA) MachineLICM pass without any success:
         -hoist-cheap-insts - MachineLICM should hoist even cheap instructions
         -disable-licm-promotion - Disable memory promotion in LICM pass
         -sink-insts-to-avoid-spills - MachineLICM should sink instructions into loops to 
avoid register spills
         -avoid-speculation - MachineLICM should avoid speculation
     (Note that llc has some other arguments related to hoisting that I did not yet use.)

     With any of these arguments I always obtain the following UNoptimized loop assembly code:
         REPEAT_X_TIMES(numRowsCols)
             R(3) = 1 ;; this instruction is a loop invariant and should be moved before 
the loop
             R(5) = LS[R(0)]
             ...
             R(1) = R(1) + R(3)
         END_REPEAT

     Could you please tell me if I can optimize this kind of loops with the post-RA 
MachineLICM?

   Thank you very much,
     Alex


More information about the llvm-dev mailing list