Skip to content

Commit

Permalink
JIT: fix USHR, optimize SHR, AND, OR, XOR
Browse files Browse the repository at this point in the history
1) USHR(-1, -1) wrongly produced -1;
2) The "best_int" check is redundant for all bitwise ops except SHL;
3) SHR, USHR, AND, OR, XOR performed unnecessary tag bit juggling.
  • Loading branch information
murmour committed Jan 14, 2018
1 parent f1846a1 commit d33fa7a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vm/jit_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,18 +1415,23 @@ static void jit_int_op( jit_ctx *ctx, enum IOperation op ) {
XMov_rp(ACC,SP,FIELD(0));
is_int(ACC,false,jerr1);
is_int(TMP,false,jerr2);
XShr_rc(TMP,1);
XShr_rc(ACC,1);

switch( op ) {
case IOP_SHL:
XShr_rc(ACC,1);
XShr_rc(TMP,1);
XShl_rr(ACC,TMP);
best_int();
break;
case IOP_SHR:
XShr_rc(TMP,1);
XShr_rr(ACC,TMP);
XOr_rc(ACC,1);
break;
case IOP_USHR:
XShr_rc(TMP,1);
XUShr_rr(ACC,TMP);
XOr_rc(ACC,1);
break;
case IOP_AND:
XAnd_rr(ACC,TMP);
Expand All @@ -1436,12 +1441,12 @@ static void jit_int_op( jit_ctx *ctx, enum IOperation op ) {
break;
case IOP_XOR:
XXor_rr(ACC,TMP);
XOr_rc(ACC,1);
break;
default:
ERROR;
}

best_int();
XJump_near(jend);

PATCH_JUMP(jerr1);
Expand Down

0 comments on commit d33fa7a

Please sign in to comment.