Description
IPv6 addresses in binary form require 128-bits, which fits __m128i
nicely 🙂 Since text representation is in hexadecimal (or two __m128i
, or one __m256i
), therefore a vectorized algorithm in it's simplest form could be a shuffle on the high four bits to determine the ASCII code by which to lower the input byte followed by a right shift of all uneven input bytes, followed by a binary OR.
The tricky part here, in my initial experiments, is the short-hand notation. e.g. ::1
. Once ::
occurs, which is basically true for all IPv6 address, the numbers are relative to the lsb rather than the msb. First getting the location of all :
's and doing a shift to end up with the location of one of the :
's in ::
allows one to quickly solve that problem. Initially, using scalar logic for coming up with two epi32
load masks seems quickest, but more experimentation is required.
Lastly, IPv6 supported a dotted notation to represent the lower 32-bits. I believe that notation is deprecated, and whether we want to support that can be debated. Should we choose to support dotted notation, a slow path may be required.