On Fri, 2009-11-20 at 10:18 -0500, David Edelsohn wrote: > On Fri, Nov 20, 2009 at 10:05 AM, Ian Bolton <bol...@icerasemi.com> wrote: > > From some simple experiments (see below), it appears as though GCC aims > > to > > create a lop-sided tree when there are constants involved (func1 below), > > but a balanced tree when there aren't (func2 below). > > > > Our assumption is that GCC likes having constants all near to each other > > to > > aid with tree-based optimisations, but I'm fairly sure that, when it > > comes > > to scheduling, it would be better to have a balanced tree, so sched has > > more > > choices about what to schedule next? > > I think this would depend on the target architecture and instruction > set: CISC vs RISC, many registers vs few registers, etc. I do not > believe that GCC intentionally is trying to optimize for either, but I > do not think there is a single, right answer. > > David
Hmm, GCC currently does tree reassociation in order to unbalance the tree. Apparently this gives better CSE -- see -fno-tree-reassoc R.