HomePhabricator

Avoid non-trivial global constants in SHA-NI code

Description

Avoid non-trivial global constants in SHA-NI code

Summary:

This is a potential solution for #18456.

It seems that the compiler cannot turn
_mm_set_epi64x(<constant>,<constnant>) into a constant itself, and thus
emits a global initializer for the MASK, INIT0, and INIT1 global
constants in the sha-ni SHA256 implementation.

Change this by turning them into dumb byte arrays, loading them into an
SSE variable whenever needed.

Tested on a SHA-NI capable machine. I do not observe any obvious
performance impact (but this is hard to measure, it's already very
fast...).

Backport of core PR18553.

Test Plan:

cmake -GNinja .. -DENABLE_SSE41=OFF -DENABLE_AVX2=OFF
ninja all check bench-bitcoin

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6278

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Apr 7 2020, 05:21
FabienCommitted on May 28 2020, 14:45
FabienPushed on May 28 2020, 14:45
Reviewer
Restricted Project
Differential Revision
D6278: Avoid non-trivial global constants in SHA-NI code
Parents
rABCeb87697b0e40: Fix deprecated ByteSize() for protobuf >= 3.1
Branches
Unknown
Tags
Unknown