[RFC] Implementing inet_pton4 and inet_pton6 on x86 using AVX512 Icelake instructions

Shreesh Adiga 16567adigashreesh@gmail.com
Sun May 3 14:31:10 GMT 2026


Hi,

I was able to implement inet_pton4 and inet_pton6 using AVX512 instructions
on my Zen4 desktop. The main advantages are very few branches and no usage
of local stack buffer and other function calls while being faster for
valid inputs.
I also used libfuzzer to implement a fuzzer which reports if the two
functions give different outputs on same input and it seems to not report
anything, so I am confident that it behaves identical.

I used libbenchmark and observed that inet_pton4 implementation is about
2-4x faster on valid inputs and inet_pton6 is slightly slower on shortest
input "::", whereas for longest inputs it is about 3-4x faster.

I'm attaching the fuzzer program which includes the inet_pton
implementation using x86 intrinsics along with the glibc reference C
functions.
clang++ -O1 -g -fsanitize=address,fuzzer -march=icelake-server fuzz.cpp -o
fuzz

I'd like to know if I can contribute this to glibc and if others think this
is a good suggestion or not. If this sounds interesting and acceptable
work, can someone provide on guidance on the high level changes to be done
in the codebase in adding a SIMD optimization and some of the previous work
on this line that would be useful in studying and replicating here.

Thanks,
Shreesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260503/6b6b855f/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fuzz.cpp
Type: text/x-c++src
Size: 18336 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260503/6b6b855f/attachment-0001.bin>


More information about the Libc-alpha mailing list