On Fri, Feb 26, 2016 at 4:02 AM, kugan <kugan.vivekanandara...@linaro.org> wrote: > > > Hi, > > This is an attempt to fix missed optimization: x+x+x+x -> 4*x as reported in > PR63586. > > Regression tested and bootstrapped on x86-64-linux-gnu with no new > regressions. > > Is this OK for next stage1?
That looks better, but I think the unordered_remove will break operand sorting and thus you probably don't handle x + x + x + x + y + y + y + y + y + y + z + z + z + z optimally. I'd say you simply want to avoid the recursion and collect a vector of [start, end] pairs before doing any modification to the ops vector. Richard. > Thanks, > Kugan > > > gcc/testsuite/ChangeLog: > > 2016-02-26 Kugan Vivekanandarajah <kug...@linaro.org> > > PR middle-end/63586 > * gcc.dg/tree-ssa/reassoc-14.c: Fix multiply count. > > gcc/ChangeLog: > > 2016-02-26 Kugan Vivekanandarajah <kug...@linaro.org> > > PR middle-end/63586 > * tree-ssa-reassoc.c (transform_add_to_multiply): New. > (reassociate_bb): Call transform_add_to_multiply. > >