[PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Jakub Jelinek
Hi! gimple_expand_builtin_pow last two optimizations rely on earlier optimizations in the same function to be performed, e.g. folding pow (x, c) for n = 2c into sqrt(x) * powi(x, n / 2) is only correct for c which isn't an integer (otherwise the sqrt(x) factor would need to be skipped), but they

Re: [PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Richard Biener
On Mon, 28 Jan 2013, Jakub Jelinek wrote: Hi! gimple_expand_builtin_pow last two optimizations rely on earlier optimizations in the same function to be performed, e.g. folding pow (x, c) for n = 2c into sqrt(x) * powi(x, n / 2) is only correct for c which isn't an integer (otherwise the

Re: [PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Bill Schmidt
LGTM! Thanks for fixing this. Bill On Mon, 2013-01-28 at 15:25 +0100, Jakub Jelinek wrote: Hi! gimple_expand_builtin_pow last two optimizations rely on earlier optimizations in the same function to be performed, e.g. folding pow (x, c) for n = 2c into sqrt(x) * powi(x, n / 2) is only

Re: [PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Marc Glisse
On Mon, 28 Jan 2013, Jakub Jelinek wrote: 2013-01-28 Jakub Jelinek ja...@redhat.com PR tree-optimization/56125 * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Don't optimize pow(x,c) into sqrt(x) * powi(x, n/2) or 1.0 / (sqrt(x) * powi(x, abs(n/2))) if c

Re: [PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Jakub Jelinek
On Mon, Jan 28, 2013 at 04:41:31PM +0100, Marc Glisse wrote: On Mon, 28 Jan 2013, Jakub Jelinek wrote: 2013-01-28 Jakub Jelinek ja...@redhat.com PR tree-optimization/56125 * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Don't optimize pow(x,c) into sqrt(x) * powi(x,

Re: [PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Marc Glisse
On Mon, 28 Jan 2013, Jakub Jelinek wrote: On Mon, Jan 28, 2013 at 04:41:31PM +0100, Marc Glisse wrote: On Mon, 28 Jan 2013, Jakub Jelinek wrote: 2013-01-28 Jakub Jelinek ja...@redhat.com PR tree-optimization/56125 * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Don't

Re: [PATCH] Fix up pow folding (PR tree-optimization/56125)

2013-01-28 Thread Jakub Jelinek
On Mon, Jan 28, 2013 at 05:07:10PM +0100, Marc Glisse wrote: There is no sqrt, x/(n*n) is just one mul and one div, whereas with the call I see one mul, 3 movs to prepare for the call, and the call. Ah, you're talking about the checked in testcase, rather than the one I've mentioned in the