https://github.com/bitcoin/bitcoin/blob/5f0c6a7b0e47e03f848dc992d37fe209dd9c6975/src/crypto/sha256.cpp#L183

This checks whether the CPU supports SSE4. It should also check if the OS supports SSE4. See this [StackOverflow answer](https://stackoverflow.com/a/22521619/6557621).
#include <crypto/sha256.h>
#include <crypto/common.h>
#include <assert.h>
#include <string.h>
#include <atomic>
#if defined(__x86_64__) || defined(__amd64__)
#if defined(USE_ASM)
#include <cpuid.h>
namespace sha256_sse4
{
void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks);
}
#endif
#endif
namespace sha256d64_sse41
{
void Transform_4way(unsigned char* out, const unsigned char* in);
}
namespace sha256d64_avx2
{
void Transform_8way(unsigned char* out, const unsigned char* in);
}
namespace
{
namespace sha256
{
uint32_t inline Ch(uint32_t x, uint32_t y, uint32_t z) { return z ^ (x & (y ^ z)); }