libera/#sicl - IRC Chatlog
Search
2:54:39
moon-child
A note: I have discovered that misaligned accesses are useful when implementing bignums. It would be nice if they were supported
2:55:10
moon-child
(presumably not as an actual language feature, but rather as an optimisation for a certain pattern of indexing on simple-arrays of (unsigned-byte 8))
3:00:32
moon-child
here's one example I just ran into: when dividing, the divisor must be 'aligned', by shifting it left such that the most significant bit of the most significant limb is 1. If the shift count happens to be divisible by 8 (which will happen a reasonable proportion of the time), the shift can be done more cheaply by doing a byte-oriented copy. However, it is possible to avoid the need to explicitly
3:00:34
moon-child
copy, by padding before the beginning with zeroes, and performing misaligned reads including this region
3:04:47
moon-child
(the order of limbs in a bignum must match the machine's endianness for this to work unconditionally. Which is partly why I suggest it be done via pattern-matching, as the code is more portable that way, and on big-endian machines the optimisation can be disabled)