avoid constant folding for -0 (to avoid it colapsing to 0)
This commit is contained in:
6
lcode.c
6
lcode.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lcode.c,v 2.34 2007/05/04 18:41:49 roberto Exp roberto $
|
** $Id: lcode.c,v 2.35 2008/04/02 16:16:06 roberto Exp roberto $
|
||||||
** Code generator for Lua
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -696,8 +696,8 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
|||||||
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OPR_MINUS: {
|
case OPR_MINUS: {
|
||||||
if (isnumeral(e)) /* -constant? */
|
if (isnumeral(e) && e->u.nval != 0) /* minus non-zero constant? */
|
||||||
e->u.nval = luai_numunm(NULL, e->u.nval);
|
e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */
|
||||||
else {
|
else {
|
||||||
luaK_exp2anyreg(fs, e);
|
luaK_exp2anyreg(fs, e);
|
||||||
codearith(fs, OP_UNM, e, &e2);
|
codearith(fs, OP_UNM, e, &e2);
|
||||||
|
|||||||
Reference in New Issue
Block a user