From 40d8832ee05096f9aea8eb54d1cdccf2646aecd0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 11 Sep 2019 10:20:10 -0300 Subject: Simplification in the call to 'constfolding' --- lcode.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 841806fd..c48bc41e 100644 --- a/lcode.c +++ b/lcode.c @@ -1630,6 +1630,8 @@ static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) { void luaK_posfix (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2, int line) { luaK_dischargevars(fs, e2); + if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2)) + return; /* done by folding */ switch (opr) { case OPR_AND: { lua_assert(e1->t == NO_JUMP); /* list closed by 'luaK_infix' */ @@ -1649,35 +1651,29 @@ void luaK_posfix (FuncState *fs, BinOpr opr, break; } case OPR_ADD: case OPR_MUL: { - if (!constfolding(fs, opr + LUA_OPADD, e1, e2)) - codecommutative(fs, opr, e1, e2, line); + codecommutative(fs, opr, e1, e2, line); break; } case OPR_SUB: case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: { - if (!constfolding(fs, opr + LUA_OPADD, e1, e2)) - codearith(fs, opr, e1, e2, 0, line); + codearith(fs, opr, e1, e2, 0, line); break; } case OPR_BAND: case OPR_BOR: case OPR_BXOR: { - if (!constfolding(fs, opr + LUA_OPADD, e1, e2)) - codebitwise(fs, opr, e1, e2, line); + codebitwise(fs, opr, e1, e2, line); break; } case OPR_SHL: { - if (!constfolding(fs, LUA_OPSHL, e1, e2)) { - if (isSCint(e1)) { - swapexps(e1, e2); - codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); - } - else - codeshift(fs, OP_SHL, e1, e2, line); + if (isSCint(e1)) { + swapexps(e1, e2); + codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); } + else + codeshift(fs, OP_SHL, e1, e2, line); break; } case OPR_SHR: { - if (!constfolding(fs, LUA_OPSHR, e1, e2)) - codeshift(fs, OP_SHR, e1, e2, line); + codeshift(fs, OP_SHR, e1, e2, line); break; } case OPR_EQ: case OPR_NE: { -- cgit v1.2.3-55-g6feb