On Sun, Mar 15, 2009 at 11:19 PM, Ramana Radhakrishnan <raman...@gmail.com> wrote: > I'm not sure about the best way to fix this but I've filed this for > the moment as > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39468
This problem is reported every once in a while, all targets with small load-immediate instructions suffer from this, especially since GCC 4.0 (i.e. since tree-ssa). But it seems there is just not enough interest in having it fixed somehow, or someone would have taken care of it by now. I've summed up before how the problem _could_ be fixed, but I can't find where. So here we go again. This could be solved in CSE by extending the notion of "related expressions" to constants that can be generated from other constants by a shift. Alternatively, you could create a simple, separate pass that applies CSE's "related expressions" thing in dominator tree walk. Another way to fix this, would be to learn RTL PRE about "injured" expressions (like in Knoop's lazy strength reduction). This would be the hardest but most complete fix. And finally, you could try to teach the "related values" patch from PR20211 (http://gcc.gnu.org/PR20211) about constants related via shifts, although it isn't very likely that this pass in the form of the patch will ever make it into the FSF GCC. Hope this helps, Ciao! Steven