diff --git a/library/stdarch/coresimd/x86/cpuid.rs b/library/stdarch/coresimd/x86/cpuid.rs index 7e000625ce81..af9f88fce0a0 100644 --- a/library/stdarch/coresimd/x86/cpuid.rs +++ b/library/stdarch/coresimd/x86/cpuid.rs @@ -96,7 +96,7 @@ pub fn has_cpuid() -> bool { let eflags: u32 = __readeflags(); // Invert the ID bit in EFLAGS: - let eflags_mod: u32 = eflags | 0x0020_0000; + let eflags_mod: u32 = eflags ^ 0x0020_0000; // Store the modified EFLAGS (ID bit may or may not be inverted) __writeeflags(eflags_mod); @@ -138,6 +138,11 @@ mod tests { assert!(cpuid::has_cpuid()); } + #[test] + fn test_has_cpuid_idempotent() { + assert_eq!(cpuid::has_cpuid(), cpuid::has_cpuid()); + } + #[cfg(target_arch = "x86")] #[test] fn test_has_cpuid() {