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).
{
    std::string ret = "standard";
#if defined(USE_ASM) && (defined(__x86_64__) || defined(__amd64__) || defined(__i386__))
    uint32_t eax, ebx, ecx, edx;
    cpuid(1, 0, eax, ebx, ecx, edx);
    if ((ecx >> 19) & 1) {
#if defined(__x86_64__) || defined(__amd64__)
        Transform = sha256_sse4::Transform;
        TransformD64 = TransformD64Wrapper<sha256_sse4::Transform>;
#endif
#if defined(ENABLE_SSE41) && !defined(BUILD_BITCOIN_INTERNAL)
        TransformD64_4way = sha256d64_sse41::Transform_4way;
        ret = "sse4(1way+4way)";
#if defined(ENABLE_AVX2) && !defined(BUILD_BITCOIN_INTERNAL)
        cpuid(7, 0, eax, ebx, ecx, edx);
        if ((ebx >> 5) & 1) {
            TransformD64_8way = sha256d64_avx2::Transform_8way;
            ret += ",avx2(8way)";
        }
#endif
#else
        ret = "sse4";
#endif
    }
#endif
    assert(SelfTest(Transform));
    return ret;
}
CSHA256::CSHA256() : bytes(0)