Page MenuHomePhabricator

Avoid non-trivial global constants in SHA-NI code
ClosedPublic

Authored by Fabien on May 28 2020, 12:44.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Commits
rABCfa124e895bd6: 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

Event Timeline

Fabien requested review of this revision.May 28 2020, 12:44

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

This revision is now accepted and ready to land.May 28 2020, 14:29