lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

>> My request for advice relates to the order of the fields in the expanded
>> 64-bit Instruction. I recall reading somewhere about Lua changing the order
>> from ABC to ACB for performance reasons, though for the life of me I have
>> been unable to find that reference. I am hoping someone else remembers where
>> that was, or some way to find it... I have tried a number of searches on the
>> list and have come up empty handed.
>> 
>> I understand the performance boost from changing ABC to ACB has to do with 
>> hardware level optimisations, but that is not a level of optimisation I am
>> terribly familiar with. I am wondering how changing from ABC to ACB results
>> in a performance gain, and given that it does, is there any way I can
>> arrange my 64-bit opcode to be more efficient then my first attempt is?
> 
> The original order (when we adopted ABC) was ABCOp (from higher to
> lower bits). Later, we changed it to BCAOp. (So, the current order
> gives the impression that B and C exchanged places, but it was A who
> changed.) The reason was only to try to keep the most used fields in the
> lower bits (because some CPUS take slighly longer to make shifts with
> larger offsets). So, as A is more used than B or C, we moved it to
> a lower position.
> 
> -- Roberto

Roberto,

Thank you for your insight, I had thought it might have been something
to do with the speed of shifting, but was not certain.

I tried to keep a boundary between the low and high portions as I
thought it may of made it easier to port this patch to a system that
does not have 64-bit support. However, I think that was probably
unnecessary and I might just rework the whole layout ignoring that
limitation. Then I could put A and Ai right after Op and work out
the remaining layout for the B/C/Bx/Cx fields.

What sort of performance gains did you see from switching to the BCA
format, and which CPUs specifically had this issue, by the way?

Thanks again,

~Paige