Bug 878444: in Range Analysis, give an empty range for |Infinity % x|; r=bhackett

This commit is contained in:
Benjamin Bouvier 2013-06-12 12:18:23 -07:00
parent 03b5b62244
commit 8bfebd11eb
2 changed files with 31 additions and 0 deletions

View File

@ -726,6 +726,11 @@ MMod::computeRange()
return;
Range lhs(getOperand(0));
Range rhs(getOperand(1));
// Infinite % x is NaN
if (lhs.isInfinite())
return;
int64_t a = Abs<int64_t>(rhs.lower());
int64_t b = Abs<int64_t>(rhs.upper());
if (a == 0 && b == 0)

View File

@ -0,0 +1,26 @@
function g()
{
function f(v) {
v = +v;
var infinity = 0.0;
var three = 0.0;
var nan = 0.;
var result = 0;
infinity = 1.0 / 0.0;
three = v + 2.0;
nan = (infinity % three);
result = ~~(nan + 42.0);
return result | 0;
}
return f
}
g = g()
var x;
for(i=0; i < 20000; ++i)
{
x = g(1.0)
}
assertEq(x, 0);