Cost in loop-strength-reduce pass

Hello. May somebody explain how cost in loop strength reduction is calculated?

E.q. I received two different costs with 3 regs and with 1reg and imms. Why second combination in preffered?

(Some from debug log)

New best at 3 regs, with addrec cost 3.
Regs: {20000,+,-1}<%for.body> {@x,+,4}<%for.body> {@y,+,4}<%for.body>
New best at 3 regs, with addrec cost 1, plus 16 imm cost.
Regs: {0,+,-1}<%for.body> @x @y