Implement the _mm256_zeroupper and _mm256_zeroall intrinsics

This commit is contained in:
Tobias Decking 2024-07-01 21:01:49 +02:00
parent 9d920ed333
commit d982844b47
No known key found for this signature in database
2 changed files with 16 additions and 0 deletions

View File

@ -338,6 +338,17 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.write_scalar(Scalar::from_i32(res.into()), dest)?;
}
// Used to implement the `_mm256_zeroupper` and `_mm256_zeroall` functions.
// These function clear out the upper 128 bits of all avx registers or
// zero out all avx registers respectively.
"vzeroupper" | "vzeroall" => {
// These functions are purely a performance hint for the CPU.
// Any registers currently in use will be saved beforehand by the
// compiler, making these functions no-ops.
// The only thing that needs to be ensured is the correct calling convention.
let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
}
_ => return Ok(EmulateItemResult::NotSupported),
}
Ok(EmulateItemResult::NeedsReturn)

View File

@ -1342,6 +1342,11 @@ unsafe fn test_avx() {
assert_eq!(r, 1);
}
test_mm_testnzc_ps();
// These intrinsics are functionally no-ops. The only thing
// that needs to be tested is that they can be executed.
_mm256_zeroupper();
_mm256_zeroall();
}
#[target_feature(enable = "sse2")]