Skip to content

Commit b0d791d

Browse files
committed
Auto merge of rust-lang#3726 - TDecking:vzero, r=RalfJung
Implement the `_mm256_zeroupper` and `_mm256_zeroall` intrinsics These two intrinsics were missing from the original implementation of the AVX intrinsics. Fortunately their implementation is trivial.
2 parents ad1d8a8 + d982844 commit b0d791d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/tools/miri/src/shims/x86/avx.rs

+11
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,17 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
338338

339339
this.write_scalar(Scalar::from_i32(res.into()), dest)?;
340340
}
341+
// Used to implement the `_mm256_zeroupper` and `_mm256_zeroall` functions.
342+
// These function clear out the upper 128 bits of all avx registers or
343+
// zero out all avx registers respectively.
344+
"vzeroupper" | "vzeroall" => {
345+
// These functions are purely a performance hint for the CPU.
346+
// Any registers currently in use will be saved beforehand by the
347+
// compiler, making these functions no-ops.
348+
349+
// The only thing that needs to be ensured is the correct calling convention.
350+
let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
351+
}
341352
_ => return Ok(EmulateItemResult::NotSupported),
342353
}
343354
Ok(EmulateItemResult::NeedsReturn)

src/tools/miri/tests/pass/shims/x86/intrinsics-x86-avx.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,11 @@ unsafe fn test_avx() {
13421342
assert_eq!(r, 1);
13431343
}
13441344
test_mm_testnzc_ps();
1345+
1346+
// These intrinsics are functionally no-ops. The only thing
1347+
// that needs to be tested is that they can be executed.
1348+
_mm256_zeroupper();
1349+
_mm256_zeroall();
13451350
}
13461351

13471352
#[target_feature(enable = "sse2")]

0 commit comments

Comments
 (0)