Hello, The purpose of the llvm.powi intrinsic isn't clear to me. Why is llvm.powi preferable to multiplication and division for small constant powers (e.g., 1/x, x*x, etc.)? Why is it preferable to llvm.pow for large variable powers? I'm also curious about the time bound. I'm assuming that powi(x,1000000) doesn't do a million multiplications... Do any architectures have an integer power instruction of some sort? Regards, Jon
> The purpose of the llvm.powi intrinsic isn't clear to me. Why is > llvm.powi preferable to multiplication and division for small constant > powers (e.g., 1/x, x*x, etc.)? Why is it preferable to llvm.pow for > large variable powers? I'm also curious about the time bound. I'm > assuming that powi(x,1000000) doesn't do a million multiplications... > Do any architectures have an integer power instruction of some sort?The purpose of this is to capture this information at a higher level, allowing the code generator top (eventually) lower it into an optimal sequence of multiplies. for example, powi(x, 9) can be lowered to: t = x*x; t2 = t*t result = t2*t2*x The code generator doesn't currently do any smart lowering, if you're interested in this, it would be a great place to dive in -Chris -- http://nondot.org/sabre/ http://llvm.org/
On Mon, 26 Nov 2007, Chris Lattner wrote:>> Do any architectures have an integer power instruction of some sort? > > The purpose of this is to capture this information at a higher level, > allowing the code generator top (eventually) lower it into an optimal"allowing the code generator to (eventually) lower it into an optimal" -Chris> sequence of multiplies. for example, powi(x, 9) can be lowered to: > > t = x*x; > t2 = t*t > result = t2*t2*x > > The code generator doesn't currently do any smart lowering, if you're > interested in this, it would be a great place to dive in > > -Chris > >-Chris -- http://nondot.org/sabre/ http://llvm.org/