Jonas Maebe wrote:
On 08 Sep 2006, at 18:30, Waldek Hebisch wrote:
gpc choose half of the wordsize as an access size and always fetches two consecutive halfwords. I guess that fixed size is used for simplicity of implementation and half of the wordsize to avoid double shifts.
Currently already uses double shifts along with several conditional jumps when using a variable index, even if you're accessing a packed array of boolean (or equivalent). The code generated for this:
Well, the current scheme was introduced many years ago. I do not say that the goals were attained. I am just trying to reconstruct the rationale.
This implementation has a number of problems. My plan was to change it. I would like to keep fixed access size -- IMHO pure byte access is the most natural one. Access to the last byte must be conditional.
So you mean always alignment 1 and rounding up to byte size?
Yes.
There is always a compromise between space (forcing bigger alignment) and number of acceses needed to fetch given value -- I do not think that we must limit number of access to two.
I thought exactly that option that was a nice a compromise between speed and space though. Especially since when having bigger elements, the rounding up of the size can be easily made more coarse grained without significantly impacting the total size of the array.
Yes. However when packing 63 bit elements on 32 bit machine (or 127 bit elements on 64 bit machine) using two acceses causes trouble -- gpc implementation would need quadruple precision shifts.
Also, I would like to have possibility to implement packed array access via call to runtime support -- using different sizes requires more support code.
I must say that my idea to use byte access is mainly motivated by simplicity of implementation. Using two acceses and varying access size is probably better, but requires (slightly) more work. gpc had a number of bugs in its packed array implementation, so I tried to find out the simplest correct way...