Debian Codegraph @

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

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