Skip to content

Commit 1c8afcc

Browse files
[TargetParser][AArch64] Believe runtime feature detection
1 parent c44d528 commit 1c8afcc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

llvm/lib/TargetParser/Host.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -1967,21 +1967,19 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
19671967
}
19681968

19691969
#if defined(__aarch64__)
1970-
// If we have all crypto bits we can add the feature
1971-
if (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2))
1972-
Features["crypto"] = true;
1970+
// LLVM has decided some AArch64 CPUs have all the instructions they _may_ have, as opposed to
1971+
// all the instructions they _must_ have, so allow runtime information to correct us on that.
1972+
Features["crypto"] = (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2));
19731973
#endif
19741974

19751975
return true;
19761976
}
19771977
#elif defined(_WIN32) && (defined(__aarch64__) || defined(_M_ARM64))
19781978
bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
1979-
if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
1980-
Features["neon"] = true;
1981-
if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE))
1982-
Features["crc"] = true;
1983-
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE))
1984-
Features["crypto"] = true;
1979+
// If we're asking the OS at runtime, believe what the OS says
1980+
Features["neon"] = IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
1981+
Features["crc"] = IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
1982+
Features["crypto"] = IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
19851983

19861984
return true;
19871985
}

0 commit comments

Comments
 (0)