Skip to content

Commit aab2431

Browse files
committed
Add environment variable STDSIMD_ASSERT_INSTR_LIMIT to control the instruction limit
1 parent 99039f6 commit aab2431

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

crates/stdsimd-test/src/lib.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ fn parse_dumpbin(output: &str) -> HashMap<String, Vec<Function>> {
257257
ret
258258
}
259259

260-
261260
#[wasm_bindgen(module = "child_process")]
262261
extern "C" {
263262
#[wasm_bindgen(js_name = execSync)]
@@ -420,26 +419,29 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
420419
break;
421420
}
422421

423-
let instruction_limit = match expected {
424-
// cpuid returns a pretty big aggregate structure so excempt it from
425-
// the slightly more restrictive 22 instructions below
426-
"cpuid" => 30,
427-
428-
// Apparently on Windows LLVM generates a bunch of saves/restores of
429-
// xmm registers around these intstructions which blows the 20
430-
// limit below. As it seems dictates by Windows's abi (I
431-
// guess?) we probably can't do much about it...
432-
"vzeroall" | "vzeroupper" if cfg!(windows) => 30,
433-
434-
// Intrinsics using `cvtpi2ps` are typically "composites" and in some
435-
// cases exceed the limit.
436-
"cvtpi2ps" => 25,
437-
438-
// Original limit was 20 instructions, but ARM DSP Intrinsics are
439-
// exactly 20 instructions long. So bump the limit to 22 instead of
440-
// adding here a long list of expections.
441-
_ => 22,
442-
};
422+
let instruction_limit = std::env::var("STDSIMD_ASSERT_INSTR_LIMIT")
423+
.map(|v| v.parse().unwrap())
424+
.unwrap_or_else(|_| match expected {
425+
// cpuid returns a pretty big aggregate structure so exempt it from
426+
// the slightly more restrictive 22 instructions below
427+
"cpuid" => 30,
428+
429+
// Apparently on Windows LLVM generates a bunch of saves/restores
430+
// of xmm registers around these intstructions which
431+
// blows the 20 limit below. As it seems dictates by
432+
// Windows's abi (I guess?) we probably can't do much
433+
// about it...
434+
"vzeroall" | "vzeroupper" if cfg!(windows) => 30,
435+
436+
// Intrinsics using `cvtpi2ps` are typically "composites" and in
437+
// some cases exceed the limit.
438+
"cvtpi2ps" => 25,
439+
440+
// Original limit was 20 instructions, but ARM DSP Intrinsics are
441+
// exactly 20 instructions long. So bump the limit to 22 instead of
442+
// adding here a long list of exceptions.
443+
_ => 22,
444+
});
443445
let probably_only_one_instruction = instrs.len() < instruction_limit;
444446

445447
if found && probably_only_one_instruction && !inlining_failed {

0 commit comments

Comments
 (0)