From 2f3f07882fb4ad9c64967d7088461b1ca0a25d3a Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Fri, 22 May 2020 03:28:52 +0200 Subject: Fix bytecode register allocation for comparisons. --- src/lj_parse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lj_parse.c b/src/lj_parse.c index 74dd5706..e18f4bfb 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c @@ -851,9 +851,12 @@ static void bcemit_comp(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) e1 = e2; e2 = eret; /* Swap operands. */ op = ((op-BC_ISLT)^3)+BC_ISLT; expr_toval(fs, e1); + ra = expr_toanyreg(fs, e1); + rd = expr_toanyreg(fs, e2); + } else { + rd = expr_toanyreg(fs, e2); + ra = expr_toanyreg(fs, e1); } - rd = expr_toanyreg(fs, e2); - ra = expr_toanyreg(fs, e1); ins = BCINS_AD(op, ra, rd); } /* Using expr_free might cause asserts if the order is wrong. */ -- cgit v1.2.1