randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.6k stars 570 forks source link

Avoid testing multiple bits in CPUID feature checks #4290

Closed randombit closed 3 months ago

randombit commented 3 months ago

For whatever reason both GCC and Clang generate quite terrible code in this case. Instead avoid the problem by never setting a bit if one of the dependency bits is missing, for example on a (hypothetical) core with AES-NI but SSSE3, just avoid setting AES-NI bit in the first place.

coveralls commented 3 months ago

Coverage Status

coverage: 91.269% (+0.004%) from 91.265% when pulling a9c1f286540a7a5ed48821adcf9d11e3084bf822 on jack/cpuid-bit-gate into 35573b38503b5e73caf30e9dec217bbea2a92725 on master.