On 07/21/2012 06:10 AM, Oleg Endo wrote: > 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.
Having to load the "1" into a register is something common to all targets. I shouldn't think that SH should need to do anything special. Indeed, that conditional that you quote above looks very wrong. I believe you should simply recurse (or let the rtx_cost driver recurse) to find the cost of arguments to the shift. r~