diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/ion/udiv-by-u32-constant.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/ion/udiv-by-u32-constant.js | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/udiv-by-u32-constant.js b/js/src/jit-test/tests/ion/udiv-by-u32-constant.js new file mode 100644 index 0000000000..f73a6f6465 --- /dev/null +++ b/js/src/jit-test/tests/ion/udiv-by-u32-constant.js @@ -0,0 +1,110 @@ +function uint_seq(count) { + with({}){} + var arr = []; + var x = 0xfac83126; + while (count--) { + x ^= x << 13; + x ^= x >> 17; + x ^= x << 5; + arr.push(x >>> 0); + } + return arr; +} + +function test(name, asm, ion, int) { + with({}){} + let count = 10000; + let seq = uint_seq(count); + for (let x of seq) { + let rint = int(x); + let rasm = asm(x); + let rion = ion(x); + // console.log(name, x, rint, rasm, rion); + assertEq(rasm, rint); + assertEq(rion, rint); + } +} + +var asmdiv2 = (function(m) { + "use asm" + function f(x) { + x = x|0; + var z = 0; + z = ((x>>>0) / 2)>>>0; + return z|0; + } + return f; +})() + +var plaindiv2 = function(x) { + x = x|0; + var z = 0; + z = ((x>>>0) / 2)>>>0; + return z|0; +} + +var interpdiv2 = function(x) { + with({}){}; + x = x|0; + var z = 0; + z = ((x>>>0) / 2)>>>0; + return z|0; +} + +test("div2", asmdiv2, plaindiv2, interpdiv2); + +var asmdiv3 = (function(m) { + "use asm" + function f(x) { + x = x|0; + var z = 0; + z = ((x>>>0) / 3)>>>0; + return z|0; + } + return f; +})() + +var plaindiv3 = function(x) { + x = x|0; + var z = 0; + z = ((x>>>0) / 3)>>>0; + return z|0; +} + +var interpdiv3 = function(x) { + with({}){}; + x = x|0; + var z = 0; + z = ((x>>>0) / 3)>>>0; + return z|0; +} + +test("div3", asmdiv3, plaindiv3, interpdiv3); + +var asmdiv7 = (function(m) { + "use asm" + function f(x) { + x = x|0; + var z = 0; + z = ((x>>>0) / 7)>>>0; + return z|0; + } + return f; +})() + +var plaindiv7 = function(x) { + x = x|0; + var z = 0; + z = ((x>>>0) / 7)>>>0; + return z|0; +} + +var interpdiv7 = function(x) { + with({}){}; + x = x|0; + var z = 0; + z = ((x>>>0) / 7)>>>0; + return z|0; +} + +test("div7", asmdiv7, plaindiv7, interpdiv7); |