function Test(op : int, mask : int) -> int = {
let sign = UInt(Field(42, 2));
if sign == 3 then throw(Refuse("a test of sign 3"));
Load(A, SRC1, mask, 0);
Load(B, SRC2, mask, 0);
CopyValue(R, A);
if Failed() then throw(Stop());
let kind = KindOf(A);
if op != TO_SUB & op != TO_ISUB then {
foreach (i from 0 to Count(A) - 1) {
let x = At(A, i);
let y = At(B, i);
if op == TO_ADD then Put(R, i, FAdd(x, y))
else if op == TO_MUL then Put(R, i, FMul(x, y))
else if op == TO_MIN then Put(R, i, FMin(x, y))
else if op == TO_MAX then Put(R, i, FMax(x, y))
else if op == TO_FRC then Put(R, i, FSub(x, FRound(1, y)))
else if op == TO_DSX then Put(R, i, FDdx(x))
else if op == TO_DSY then Put(R, i, FDdy(x))
else if op == TO_RCP then Put(R, i, FDiv(One(), x))
else if op == TO_RSQ then Put(R, i, FInvSqrt(x))
else if op == TO_LOG then Put(R, i, FLog2(x))
else if op == TO_EXP then Put(R, i, FExp2(x))
else if op == TO_IADD then Put(R, i, IAddT(x, y))
else if op == TO_IMUL then Put(R, i, IMulT(x, y))
else if op == TO_AND then Put(R, i, AndT(x, y))
else if op == TO_OR then Put(R, i, OrT(x, y))
else if op == TO_XOR then Put(R, i, XorT(x, y))
else if op == TO_SHL then Put(R, i, ShlT(x, y))
else if op == TO_SHR then Put(R, i, ShrT(x, y))
else if op == TO_ASR then Put(R, i, AsrT(x, y))
else if op == TO_ROL then Put(R, i, RotateLeft(x, y, 32))
};
if op == TO_DP then { /* the sum of the products, compared once */
var sum : bits(32) = FMul(At(A, 0), At(B, 0));
foreach (i from 1 to Count(A) - 1) { sum = FFma(At(A, i), At(B, i), sum) };
Put(R, 0, sum);
SetCount(R, 1)
};
foreach (i from 0 to Count(R) - 1) Put(B, i, ZeroOf(kind))
};
let eq = UInt(Field(40, 2)) == 1;
foreach (i from 0 to Count(R) - 1) SetTest(i, TestCompare(kind, eq, sign, At(R, i), At(B, i)));
Count(R)
}Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Vita3K's usse_translator_entry.cpp (GPL-2.0-or-later).