]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
Fix an issue with the ubsan for overflow
authorAdam Stylinski <kungfujesus06@gmail.com>
Fri, 18 Mar 2022 23:18:10 +0000 (19:18 -0400)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 24 Mar 2022 10:18:16 +0000 (11:18 +0100)
commit23c9191c01bf54f9d1ee03e3e82fac0aebcc1f15
tree74d7ef9edc66be3843aea6925fc9adf0453a713b
parent523dfefc60c261bf0b8b73ab85116b5a3bc1bd29
Fix an issue with the ubsan for overflow

While this didn't _actually_ cause any issues for us, technically the
_mm512_reduce_add_epi32() intrinsics returns a signed integer and it
does the very last summation in scalar GPRs as signed integers. While
the ALU still did the math properly (the negative representation is the
same addition in hardware, just interpreted differently), the sanitizer
caught window of inputs here definitely outside the range of a signed
integer for this immediate operation.

The solution, as silly as it may seem, would be to implement our own 32
bit horizontal sum function that does all of the work in vector
registers. This allows us to implicitly keep things in vector register
domain and convert at the very end after we've summed the summation.

The compiler's sanitizer doesn't know the wiser and the solution still
results in being correct.
CMakeLists.txt
arch/x86/adler32_avx512.c
arch/x86/adler32_avx512_p.h [new file with mode: 0644]
arch/x86/adler32_avx512_vnni.c