Avoid conversion narrowing of arithmetic with large constants.

This commit is contained in:
Mike Pall 2011-08-26 20:29:05 +02:00
parent 6627744752
commit 32c1d4751a

View File

@ -284,7 +284,8 @@ static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth)
}
} else {
int32_t k = lj_num2int(n);
if (n == (lua_Number)k) { /* Only if constant is really an integer. */
/* Only if constant is a small integer. */
if (checki16(k) && n == (lua_Number)k) {
*nc->sp++ = NARROWINS(NARROW_INT, 0);
*nc->sp++ = (NarrowIns)k;
return 0;