avoid constant folding for -0 (to avoid it colapsing to 0)

This commit is contained in:
Roberto Ierusalimschy 2008-04-07 15:41:47 -03:00
parent 2b84e36b93
commit 4d7469b610
1 changed files with 3 additions and 3 deletions

View File

@ -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
** 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;
switch (op) {
case OPR_MINUS: {
if (isnumeral(e)) /* -constant? */
e->u.nval = luai_numunm(NULL, e->u.nval);
if (isnumeral(e) && e->u.nval != 0) /* minus non-zero constant? */
e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */
else {
luaK_exp2anyreg(fs, e);
codearith(fs, OP_UNM, e, &e2);