aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2016-12-09 18:16:12 +0100
committerMike Pall <mike>2016-12-09 18:16:12 +0100
commit44b99ff14d0a543da54fce27793464edbbfacd16 (patch)
tree58913aeb312ad367257ee80bb2cc4e9dc3275dcd /src
parentec2756ba786cd68a0af37ec8ffe806f3ce392d7d (diff)
downloadluajit-44b99ff14d0a543da54fce27793464edbbfacd16.tar.gz
luajit-44b99ff14d0a543da54fce27793464edbbfacd16.tar.bz2
luajit-44b99ff14d0a543da54fce27793464edbbfacd16.zip
ARM64: Fuse BOR(BSHL, BSHR) into EXTR/ROR.
Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
Diffstat (limited to 'src')
-rw-r--r--src/lj_asm_arm64.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h
index ab0de5cd..b771d2f1 100644
--- a/src/lj_asm_arm64.h
+++ b/src/lj_asm_arm64.h
@@ -378,6 +378,34 @@ static int asm_fuseandshift(ASMState *as, IRIns *ir)
378 return 0; 378 return 0;
379} 379}
380 380
381/* Fuse BOR(BSHL, BSHR) into EXTR/ROR. */
382static int asm_fuseorshift(ASMState *as, IRIns *ir)
383{
384 IRIns *irl = IR(ir->op1), *irr = IR(ir->op2);
385 lua_assert(ir->o == IR_BOR);
386 if (!neverfuse(as) && ((irl->o == IR_BSHR && irr->o == IR_BSHL) ||
387 (irl->o == IR_BSHL && irr->o == IR_BSHR))) {
388 if (irref_isk(irl->op2) && irref_isk(irr->op2)) {
389 IRRef lref = irl->op1, rref = irr->op1;
390 uint32_t lshift = IR(irl->op2)->i, rshift = IR(irr->op2)->i;
391 if (irl->o == IR_BSHR) { /* BSHR needs to be the right operand. */
392 uint32_t tmp2;
393 IRRef tmp1 = lref; lref = rref; rref = tmp1;
394 tmp2 = lshift; lshift = rshift; rshift = tmp2;
395 }
396 if (rshift + lshift == (irt_is64(ir->t) ? 64 : 32)) {
397 A64Ins ai = irt_is64(ir->t) ? A64I_EXTRx : A64I_EXTRw;
398 Reg dest = ra_dest(as, ir, RSET_GPR);
399 Reg left = ra_alloc1(as, lref, RSET_GPR);
400 Reg right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, left));
401 emit_dnm(as, ai | A64F_IMMS(rshift), dest, left, right);
402 return 1;
403 }
404 }
405 }
406 return 0;
407}
408
381/* -- Calls --------------------------------------------------------------- */ 409/* -- Calls --------------------------------------------------------------- */
382 410
383/* Generate a call to a C function. */ 411/* Generate a call to a C function. */
@@ -1460,8 +1488,14 @@ static void asm_band(ASMState *as, IRIns *ir)
1460 asm_bitop(as, ir, A64I_ANDw); 1488 asm_bitop(as, ir, A64I_ANDw);
1461} 1489}
1462 1490
1491static void asm_bor(ASMState *as, IRIns *ir)
1492{
1493 if (asm_fuseorshift(as, ir))
1494 return;
1495 asm_bitop(as, ir, A64I_ORRw);
1496}
1497
1463#define asm_bnot(as, ir) asm_bitop(as, ir, A64I_MVNw) 1498#define asm_bnot(as, ir) asm_bitop(as, ir, A64I_MVNw)
1464#define asm_bor(as, ir) asm_bitop(as, ir, A64I_ORRw)
1465#define asm_bxor(as, ir) asm_bitop(as, ir, A64I_EORw) 1499#define asm_bxor(as, ir) asm_bitop(as, ir, A64I_EORw)
1466 1500
1467static void asm_bswap(ASMState *as, IRIns *ir) 1501static void asm_bswap(ASMState *as, IRIns *ir)