1 //@ skip if $hostOS == "windows"
3 // Verify that the dividend propagate the NeedsNegZero if the dividend requires it.
4 function moduloWithNegativeZeroDividend(a
, b
, c
)
9 noInline(moduloWithNegativeZeroDividend
);
11 // Warm up with integers. The test for NegZero should not be eliminated here.
12 for (var i
= 1; i
< 1e4
; ++i
) {
13 var result
= moduloWithNegativeZeroDividend(i
, 5, 5);
15 throw "moduloWithNegativeZeroDividend(i, 5, 5), returned: " + result
;
18 for (var i
= 1; i
< 1e4
; ++i
) {
19 // Produce negative zero in the multiplication.
20 var result
= moduloWithNegativeZeroDividend(-i
, 0, 2);
21 if (!(result
=== 0 && (1/result
) === -Infinity
))
22 throw "moduloWithNegativeZeroDividend(-i, 0, 2) failed, returned: " + result
;
24 // A negative dividend can produce negative zero results.
25 var result
= moduloWithNegativeZeroDividend(-i
, 5, 5);
26 if (!(result
=== 0 && (1/result
) === -Infinity
))
27 throw "moduloWithNegativeZeroDividend(-i, 5, 5) failed, returned: " + result
;
31 for (var i
= 1; i
< 1e4
; ++i
) {
32 var result
= moduloWithNegativeZeroDividend(-i
, 0, Infinity
);
33 if (!(result
=== 0 && (1/result
) === -Infinity
))
34 throw "moduloWithNegativeZeroDividend(-i, 0, Infinity) failed, returned: " + result
;
36 var result
= moduloWithNegativeZeroDividend(-i
, 0, -Infinity
);
37 if (!(result
=== 0 && (1/result
) === -Infinity
))
38 throw "moduloWithNegativeZeroDividend(-i, 0, -Infinity) failed, returned: " + result
;
40 var result
= moduloWithNegativeZeroDividend(-i
, 0, NaN
);
41 if (result
=== result
)
42 throw "moduloWithNegativeZeroDividend(-i, 0, NaN) failed, returned: " + result
;
46 // In this case, the negative zero is irrelevant. The Neg Zero check can be eliminated.
47 function moduloWithUnusedNegativeZeroDividend(a
, b
, c
)
50 return (temp
% c
) | 0;
52 noInline(moduloWithUnusedNegativeZeroDividend
);
54 for (var i
= 1; i
< 1e4
; ++i
) {
55 var result
= moduloWithUnusedNegativeZeroDividend(i
, 5, 5);
57 throw "moduloWithUnusedNegativeZeroDividend(i, 5, 5), returned: " + result
;
60 // Produce negative zero in the multiplication.
61 for (var i
= 1; i
< 1e4
; ++i
) {
62 var result
= moduloWithUnusedNegativeZeroDividend(-i
, 0, 2);
63 if (!(result
=== 0 && (1/result
) === Infinity
))
64 throw "moduloWithUnusedNegativeZeroDividend(-i, 0, 2) failed, returned: " + result
;
67 for (var i
= 1; i
< 1e4
; ++i
) {
68 var result
= moduloWithUnusedNegativeZeroDividend(-i
, 0, Infinity
);
69 if (!(result
=== 0 && (1/result
) === Infinity
))
70 throw "moduloWithUnusedNegativeZeroDividend(-i, 0, Infinity) failed, returned: " + result
;
72 var result
= moduloWithUnusedNegativeZeroDividend(-i
, 0, -Infinity
);
73 if (!(result
=== 0 && (1/result
) === Infinity
))
74 throw "moduloWithUnusedNegativeZeroDividend(-i, 0, -Infinity) failed, returned: " + result
;
76 var result
= moduloWithUnusedNegativeZeroDividend(-i
, 0, NaN
);
78 throw "moduloWithUnusedNegativeZeroDividend(-i, 0, NaN) failed, returned: " + result
;
82 // The sign of the divisor is completely irrelevant. This should never fail on negative zero divisors.
83 function moduloWithNegativeZeroDivisor(a
, b
, c
)
88 noInline(moduloWithNegativeZeroDivisor
);
90 // Warm up with integers.
91 for (var i
= 1; i
< 1e4
; ++i
) {
92 var result
= moduloWithNegativeZeroDivisor(i
, 2, i
);
94 throw "moduloWithNegativeZeroDividend(i, 2, i), returned: " + result
;
96 var result
= moduloWithNegativeZeroDivisor(-i
, 2, i
);
98 throw "moduloWithNegativeZeroDividend(-i, 2, i), returned: " + result
;
101 // Produce negative zero in the multiplication.
102 for (var i
= 1; i
< 1e4
; ++i
) {
103 var result
= moduloWithNegativeZeroDivisor(-i
, 0, 2);
104 if (result
=== result
)
105 throw "moduloWithNegativeZeroDivisor(-i, 0, 2) failed, returned: " + result
;