summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/udiv-by-constant.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/ion/udiv-by-constant.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/ion/udiv-by-constant.js')
-rw-r--r--js/src/jit-test/tests/ion/udiv-by-constant.js114
1 files changed, 114 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/udiv-by-constant.js b/js/src/jit-test/tests/ion/udiv-by-constant.js
new file mode 100644
index 0000000000..43549cd1e7
--- /dev/null
+++ b/js/src/jit-test/tests/ion/udiv-by-constant.js
@@ -0,0 +1,114 @@
+function uint_seq(count) {
+ with({}){}
+ var arr = [];
+ var x = 0xfac83126;
+ while (count--) {
+ x ^= x << 13;
+ x ^= x >> 17;
+ x ^= x << 5;
+ // SpiderMonkey does not know how to represent UInt32, only Int32, and
+ // including any UInt32 will cause the following function to be
+ // de-optimized as double math.
+ if (x|0 > 0)
+ 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 asmdiv5 = (function(m) {
+ "use asm"
+ function f(x) {
+ x = x|0;
+ var z = 0;
+ z = ((x>>>0) / 5)>>>0;
+ return z|0;
+ }
+ return f;
+})()
+
+var plaindiv5 = function(x) {
+ x = x|0;
+ var z = 0;
+ z = ((x>>>0) / 5)>>>0;
+ return z|0;
+}
+
+var interpdiv5 = function(x) {
+ with({}){};
+ x = x|0;
+ var z = 0;
+ z = ((x>>>0) / 5)>>>0;
+ return z|0;
+}
+
+test("div5", asmdiv5, plaindiv5, interpdiv5);
+
+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);