diff options
Diffstat (limited to 'src/lj_opt_narrow.c')
-rw-r--r-- | src/lj_opt_narrow.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lj_opt_narrow.c b/src/lj_opt_narrow.c index 1727e9b5..e7f280ec 100644 --- a/src/lj_opt_narrow.c +++ b/src/lj_opt_narrow.c | |||
@@ -535,6 +535,21 @@ TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, | |||
535 | return emitir(IRTN(op), rb, rc); | 535 | return emitir(IRTN(op), rb, rc); |
536 | } | 536 | } |
537 | 537 | ||
538 | /* Narrowing of unary minus operator. */ | ||
539 | TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc) | ||
540 | { | ||
541 | if (tref_isstr(rc)) { | ||
542 | rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); | ||
543 | lj_str_tonum(strV(vc), vc); | ||
544 | } | ||
545 | if (tref_isinteger(rc)) { | ||
546 | if ((uint32_t)numberVint(vc) != 0x80000000u) | ||
547 | return emitir(IRTGI(IR_SUBOV), lj_ir_kint(J, 0), rc); | ||
548 | rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); | ||
549 | } | ||
550 | return emitir(IRTN(IR_NEG), rc, lj_ir_knum_neg(J)); | ||
551 | } | ||
552 | |||
538 | /* Narrowing of modulo operator. */ | 553 | /* Narrowing of modulo operator. */ |
539 | TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc) | 554 | TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc) |
540 | { | 555 | { |