// |jit-test| skip-if: !wasmSimdEnabled() || wasmCompileMode() != "ion" || (!getBuildConfiguration("x86") && !getBuildConfiguration("x64")) || getBuildConfiguration("simulator")
const avx = isAvxPresent();
for (let [n1, n2, numInstr] of [
[0 x123456789abn, 0 xffeeddccbbaa9988n, avx ? 6 : 7 ],
[42 n, 0 xFFFFFFFFn, avx ? 3 : 4 ],
[0 n, 0 n, 1 ],
[1 n, 1 n, 1 ],
...iota(63 ).map(i => [2 n << BigInt(i), 2 n << BigInt(i), 1 ]),
...iota(63 ).reduce((acc, i) => {
const base = 2 n << BigInt(i);
return acc.concat(iota(i + 1 ).map(j => [
base | (1 n << BigInt(j)), base | (1 n << BigInt(j)),
(avx ? 2 : 3 ) + (j == 0 ? 0 : 1 )]));
}, []),
...iota(63 ).map(i => [~(1 n << BigInt(i)), ~(1 n << BigInt(i)), avx ? 5 : 6 ]),
[0 x7fffffffffffffffn, 0 x7fffffffffffffffn, avx ? 5 : 6 ],
[-1 n, -1 n, 3 ],
]) {
var wasm = wasmTextToBinary(`(module
(memory (export "memory" ) 1 1 )
(func $t (export "t" ) (param v128) (result v128)
local.get 0
v128.const i64x2 ${n1} ${n2}
i64x2.mul
)
(func $t0 (param v128 v128) (result v128)
local.get 0
local.get 1
i64x2.mul
)
(func (export "run" ) (result i32)
i32.const 16
i32.const 0
v128.load
call $t
v128.store
v128.const i64x2 ${n1} ${n2}
i32.const 0
v128.load
call $t0
i32.const 16
v128.load
i64x2.eq
i64x2.all_true
)
)`)
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasm));
var mem64 = new BigInt64Array(ins.exports.memory.buffer, 0 , 4 );
for (let [t1, t2] of [
[1 n, 1 n], [-1 n, -2 n], [0 n, 0 n], [0 x123456789abn, 0 xffeeddccbbaa9988n],
[0 x100001111n, -0 xFF0011n], [5555 n, 0 n],
]) {
mem64[0 ] = t1; mem64[1 ] = t2;
assertEq(ins.exports.run(), 1 );
}
if (hasDisassembler() && getBuildConfiguration("x64" )) {
const dis = wasmDis(ins.exports.t, {asString: true ,});
const lines = getFuncBody(dis).trim().split('\n' );
assertEq(lines.length, numInstr);
}
}
// Utils.
function getFuncBody(dis) {
const parts = dis.split(/mov %rsp, %rbp\n|^[0 -9 A-Fa-f ]+pop %rbp/gm);
return parts.at(-2 ).replace(/[0 -9 A-F]{8 } (?: [0 -9 a-f]{2 })+[\s\n]+/g, "" );
}
Messung V0.5 in Prozent C=98 H=84 G=91
¤ Dauer der Verarbeitung: 0.7 Sekunden
¤
*© Formatika GbR, Deutschland