On Wed, Feb 03, 2010 at 06:23:19AM -0800, Ian Lance Taylor wrote: > fanqifei <fanqi...@gmail.com> writes: > > > According to the internal manual, insn length attribute can be used to > > to calculate the length of emitted code chunks when verifying branch > > distances. > > Can it be used in code size optimization? > > I suppose it could, but it isn't. Instead of asking the backend for > the length of instructions, the compiler asks the backend for the cost > of instructions. The backend is free to determine that cost however > it likes. When using -Os, using the size of the instruction is a good > measure of cost.
It seems to me that there's a hard ordering problem here: we can't determine insn lengths, using the current framework, until very late. We need at least (A) whole instructions, not just RTL expressions; (B) register allocation to select alternatives; (C) branch shortening to determine branch alternatives. I'm curious if anyone thinks there's a generic solution to this (that doesn't involve a complete instruction selection rewrite :-). -- Daniel Jacobowitz CodeSourcery