On Friday 06 February 2009, Ian Lance Taylor wrote: > Jean Christophe Beyler <jean.christophe.bey...@gmail.com> writes: > > All of these have an outer code of SET. Therefore, I'm not quite > > positive of how I'm supposed to implement my rtx_cost function. Since > > I don't seem to get a choice between a set 0xcb03 and a (plus 0xcafe > > 5), how can I tell the compiler the different costs? > > Make the CONST_INT more expensive than the PLUS. > > But I don't know that gcc will implement the particular optimization > that you are looking for. I'm not aware of any other processor which is > able to load a large constant in a single instruction, but for which an > add instruction is cheaper if there is a similar constant already > available.
This is true for Arm/Thumb. You have limited immediate values for [cheap] ALU instructions (mov/add), but can also load arbitrary constants from a pool with a single [relatively expensive] pc-relative load. We lie about what immediate we can load, then fix this up in md-reorg. A quick test shows gcc manages to DTRT at least some of the time. Paul