This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use a tmp-memory to reduce register pressure?


Hi,


 I have two loops, where scheduling the inner loop fails with ii = 15 because of high register pressure. (I am using linear assembly):


;* Searching for software pipeline schedule at ...
;* ii = 15 Register pressure too high: 38
;* ii = 15 Did not find schedule
;* ii = 16 Schedule found with 3 iterations in parallel

 

Because there are a few "cold" registers, which are only accessed in the outer loop, I thought about using some temporary memory location (like the stack) to store those values to make more registers available for scheduling the inner loop. So what I do now is:


OUTERLOOP: 

 LDW *regStack[0], coldReg1
 LDW *regStack[1], coldReg2
 LDW *regStack[2], coldReg3
 LDW *regStack[3], coldReg4

  ; Do a bit with the values in the cold registers

INNERLOOP
; Some very hot code

BDEC  INNERLOOP, iLoopCnt
BDEC OUTERLOOP, oLoopCnt  

  MV imgWidth, xLoopCnt

 
 However that doesn't seem to help - the "Regs Live Always" count doesn't change, and the code produced doesn't differ either - like the optimizer doesn't recognize those registers can be re-used, because at the next iteration the old values will be restored anyway. I also tried putting those LDWs right after the inner loop's branch, but it didn't help either.
Is there any way to make more registers available by moving cold registers to a temporary storage?


Thx 

  • The compiler already stores register values on the stack and re-loads them when needed; this is called register spilling.  If you are manually spilling in the outer loop, you're not going to change the compiler's ability to software pipeline the inner loop.

    What is the value of "regs live always"?

  • Hi Archaelogist,

    Thanks for your promt reply. There indeed seems to be some spilling - so unfourtunatly this idea won't bring me down to 15 cycles :/

    I don't know the "regs live always" value for this loop unfourtunatly - I tried the same with another loop where the "regs live always" was displayed and it didn't change when manually spolling. Is there some switch to get the "regs live always" value in case.

    Thx