[LLVMdev] Cost in loop-strength-reduce pass

Andrew Trick atrick at apple.com
Thu Mar 6 00:25:48 PST 2014


On Mar 3, 2014, at 2:52 AM, alexey ivannikov <a.ye.ivannikov at gmail.com> wrote:

> 
> 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}<nw><%for.body> {@x,+,4}<nsw><%for.body> {@y,+,4}<nsw><%for.body>
> New best at 3 regs, with addrec cost 1, plus 16 imm cost.
>  Regs: {0,+,-1}<nw><%for.body> @x @y

The addrec cost is the cost of a recurrence whose value is stored in a register. So those registers need to be live throughout the entire loop. LSR tries to minimize those.

-Andy

> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list