Debian Codegraph @

js/src/jit-test/tests/warp/math-f16round-produce-float32-input-is-int32.js

raw
1 function sqrt_float32(v) {
2 return Math.fround(Math.sqrt(Math.fround(v|0)));
3 }
4
5 function sqrt_float16(v) {
6 return Math.fround(Math.sqrt(Math.f16round(v|0)));
7 }
8
9 function abs_float32(v) {
10 return Math.fround(Math.abs(Math.fround(v|0)));
11 }
12
13 function abs_float16(v) {
14 return Math.fround(Math.abs(Math.f16round(v|0)));
15 }
16
17 function ceil_float32(v) {
18 return Math.fround(Math.abs(Math.fround(v|0)));
19 }
20
21 function ceil_float16(v) {
22 return Math.fround(Math.abs(Math.f16round(v|0)));
23 }
24
25 function mul_float32(v) {
26 return Math.fround(Math.fround(v|0) * 2);
27 }
28
29 function mul_float16(v) {
30 return Math.fround(Math.f16round(v|0) * 2);
31 }
32
33 function cmp_float32(v) {
34 return Math.fround(v|0) < 1000;
35 }
36
37 function cmp_float16(v) {
38 return Math.f16round(v|0) < 1000;
39 }
40
41 // Don't inline functions into the global scope.
42 with ({}) ;
43
44 for (let i = 0; i <= 2048; ++i) {
45 assertEq(sqrt_float16(i), sqrt_float32(i));
46 assertEq(abs_float16(i), abs_float32(i));
47 assertEq(ceil_float16(i), ceil_float32(i));
48 assertEq(mul_float16(i), mul_float32(i));
49 assertEq(cmp_float16(i), cmp_float32(i));
50 }