Re: Optimizing floating point *(2^c) and /(2^c)

2010-04-01 Thread Paolo Bonzini
On 03/31/2010 11:25 AM, Vincent Lefevre wrote: On 2010-03-31 11:04:03 +0200, Marc Glisse wrote: IMHO this transformation mostly makes sense for the -ffinite-math-only case where you can replace: "put a constant and multiply/divide" by "put a constant and add/sub" and never care about extracting

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-31 Thread Geert Bosch
On Mar 29, 2010, at 16:30, Tim Prince wrote: > gcc used to have the ability to replace division by a power of 2 by an fscale > instruction, for appropriate targets (maybe still does). The problem (again) is that floating point multiplication is just too damn fast. On x86, even though the latency

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-31 Thread Vincent Lefevre
On 2010-03-31 11:04:03 +0200, Marc Glisse wrote: > IMHO this transformation mostly makes sense for the > -ffinite-math-only case where you can replace: "put a constant and > multiply/divide" by "put a constant and add/sub" and never care > about extracting the exponent, overflowing, or anything els

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-31 Thread Marc Glisse
On Wed, 31 Mar 2010, Vincent Lefevre wrote: On 2010-03-30 20:36:04 +0200, Jeroen Van Der Bossche wrote: > The if statement is there exactly to address under- and overflow and > nothing else. It's not because it looks simple that I didn't think > it through. I know exactly how floating point mult

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-30 Thread Vincent Lefevre
On 2010-03-30 20:36:04 +0200, Jeroen Van Der Bossche wrote: > The if statement is there exactly to address under- and overflow and > nothing else. It's not because it looks simple that I didn't think > it through. I know exactly how floating point multiplication works, > and this implementation of

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-30 Thread Jeroen Van Der Bossche
On 29 March 2010 19:51, Geert Bosch wrote: > > On Mar 29, 2010, at 13:19, Jeroen Van Der Bossche wrote: > >> 've recently written a program where taking the average of 2 floating >> point numbers was a real bottleneck. I've looked into the assembly >> generated by gcc -O3 and apparently gcc treats

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-29 Thread Tim Prince
On 3/29/2010 10:51 AM, Geert Bosch wrote: On Mar 29, 2010, at 13:19, Jeroen Van Der Bossche wrote: 've recently written a program where taking the average of 2 floating point numbers was a real bottleneck. I've looked into the assembly generated by gcc -O3 and apparently gcc treats multipli

Re: Optimizing floating point *(2^c) and /(2^c)

2010-03-29 Thread Geert Bosch
On Mar 29, 2010, at 13:19, Jeroen Van Der Bossche wrote: > 've recently written a program where taking the average of 2 floating > point numbers was a real bottleneck. I've looked into the assembly > generated by gcc -O3 and apparently gcc treats multiplication and > division by a hard-coded 2 li