ron minnich rminnich@lanl.gov writes:
On 6 Jul 2004, Eric W. Biederman wrote:
Hmm.. Using bytes does not help the register pressure and in fact slightly increases code size. If the byte register instructions on x86 were more symmetric this might be different, but...
sad that they don't work well.
They work well unless you are register starved, and since romcc is always register starved they don't work well in that context. There are no general register to register move instructions to let me move a byte register into a longer register and vice versa. So generally I don't even bother with the byte registers.
I cannot think of an architecture where using bytes would be better. The increase in code size is because of the need to clamp the values at their maximum so code like this fails properly.
They exist :-)
Where bytes are better for register pressure?
Beyond the theoretical case where something could be built I would love to see one. Note this is limited to treating any instruction set as a load/store architecture, because register to memory instructions can't be used. Which is the primary thing that cripples the x86 case and bytes.
thanks for the tip, this is very good to know.
There are 2 important cases for registers. 1) Using them. 2) Storing data in them.
When you are using a register it is best to have the value unpacked and to just use that register.
When you are simply storing data in a register the trade offs change because you can afford a second register to hold the value when you take it out and modify it.
For optimizing the storage case I have implemented bitfields. When they are unpacked and being manipulated they need an extra. In the cases where registers are tight bitfields could be handy, in structures could be handy for passing around multiple values. A loop counter usually does not fit that description though. Especially not when you don't have something else to put in the same register.
Since values are mostly used and not stored in registers I leave it up to the programmer to implement the storage optimization case. Although by implementing bitfields I am as helpful as I can be.
Eric