Skip to content

Commit 56265e5

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

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

llvm/lib/TargetParser/Host.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,21 +1967,23 @@ 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_
1971+
// have, as opposed to all the instructions they _must_ have, so allow runtime
1972+
// information to correct us on that.
1973+
Features["crypto"] = (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2));
19731974
#endif
19741975

19751976
return true;
19761977
}
19771978
#elif defined(_WIN32) && (defined(__aarch64__) || defined(_M_ARM64))
19781979
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;
1980+
// If we're asking the OS at runtime, believe what the OS says
1981+
Features["neon"] =
1982+
IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
1983+
Features["crc"] =
1984+
IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
1985+
Features["crypto"] =
1986+
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
19851987

19861988
return true;
19871989
}

0 commit comments

Comments
 (0)