On Sat, 2012-07-21 at 14:41 +0200, Steven Bosscher wrote: > On Fri, Jul 20, 2012 at 12:41 AM, Richard Henderson <r...@redhat.com> wrote: > > Notes for future cleanups: > > > >> + /* If the targer has no lshift in word_mode, the operation will most > >> + probably not be cheap. ??? Does GCC even work for such targets? */ > > > > Yes, it does. We're perfectly happy to let this expand to a libcall. > > Indeed, many teeny tiny targets don't have a full barrel shifter and only > > implement x << 1. See sh1, avr, etc. > > Thanks for those references! I'll fix this comment with some > references into the machine descriptions of those ports. >
I think on SH the cost test in lshift_cheap_p with gen_rtx_ASHIFT (word_mode, const1_rtx, reg), speed_p); will always 'fail', because of sh.c (shiftcosts): /* There is no pattern for constant first operand. */ if (CONST_INT_P (XEXP (x, 0))) return MAX_COST; On SH3 / SH4* / SH2A there is a dynamic shift that does "reg << reg" or "reg >> reg", which is not that expensive actually. However, the constant "1" must be loaded into a register first. I'm currently trying to brush up the shift code in SH a little bit and could add some things to handle the "const << reg" case. Or would it be better to make the lshift_cheap_p try out more shifty things? Cheers, Oleg