On Fri, May 13, 2011 at 6:00 PM, Nathan Froyd <froy...@codesourcery.com> wrote: > On 05/13/2011 11:26 AM, Richard Guenther wrote: >> On Fri, May 13, 2011 at 5:01 PM, Nathan Froyd <froy...@codesourcery.com> >> wrote: >>> On 05/13/2011 10:52 AM, William J. Schmidt wrote: >>>> This patch addresses PR46728, which notes that pow and powi need to be >>>> lowered in tree phases to restore lost FMA opportunities and expose >>>> vectorization opportunities. >>>> >>>> +struct gimple_opt_pass pass_lower_pow = >>>> +{ >>>> + { >>>> + GIMPLE_PASS, >>>> + "lower_pow", /* name */ >>>> + NULL, /* gate */ >>> >>> Please make this controlled by an option; this pass doesn't need to be run >>> all >>> the time. >>> >>> IMHO, the pass shouldn't run at anything less than -O3, but that's for other >>> people to decide. >> >> It was run unconditionally before, so unless we preserve the code at >> expansion time we have to do it here. > > We were doing it unconditionally before because we were calling it through > folding and expansion, both of which only fired if we were expanding pow > calls; now we're groveling over the whole IR to look for optimization > opportunities that, let's be honest, the vast majority of code is never going > to care about. The whole point of the patch is "to restore lost FMA > opportunities and expose vectorization opportunities". The first reason > *might* be good justification for running it at -O2, but the second reason > calls for -O3 or at the very least flag_tree_vectorize.
The patch of course does more, like expanding to power series. > However, I don't think anybody's going to notice/care if -O1 stopped folding > pow calls; could we at least add a flag_expensive_optimizations && optimize > gate? The pass doesn't look very expensive and the IL walk could be shared with cse_sincos. Note that I agree that the transforms probably should never have been applied at -O0 (we IMHO do too much builtin folding at -O0 which can be surprising - like transforming pow (x, 0.5) to sqrt (x)). So I wouldn't worry about losing the -O0 transforms at all. Richard. > -Nathan > >