aboutsummaryrefslogtreecommitdiff
path: root/src/lj_opt_mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_opt_mem.c')
-rw-r--r--src/lj_opt_mem.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c
index 9b96d66e..d47706fb 100644
--- a/src/lj_opt_mem.c
+++ b/src/lj_opt_mem.c
@@ -523,6 +523,50 @@ doemit:
523 return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ 523 return EMITFOLD; /* Otherwise we have a conflict or simply no match. */
524} 524}
525 525
526/* -- XLOAD forwarding ---------------------------------------------------- */
527
528/* NYI: Alias analysis for XLOAD/XSTORE. */
529static AliasRet aa_xref(jit_State *J, IRIns *refa, IRIns *refb)
530{
531 UNUSED(J); UNUSED(refa); UNUSED(refb);
532 return ALIAS_MAY;
533}
534
535/* XLOAD forwarding. */
536TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J)
537{
538 IRRef xref = fins->op1;
539 IRRef lim = xref; /* Search limit. */
540 IRIns *xr = IR(xref);
541 IRRef ref;
542
543 if ((fins->op2 & IRXLOAD_READONLY))
544 goto cselim;
545
546 /* Search for conflicting stores. */
547 ref = J->chain[IR_XSTORE];
548 while (ref > xref) {
549 IRIns *store = IR(ref);
550 switch (aa_xref(J, xr, IR(store->op1))) {
551 case ALIAS_NO: break; /* Continue searching. */
552 case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */
553 case ALIAS_MUST: return store->op2; /* Store forwarding. */
554 }
555 ref = store->prev;
556 }
557
558cselim:
559 /* Try to find a matching load. Below the conflicting store, if any. */
560 ref = J->chain[IR_XLOAD];
561 while (ref > lim) {
562 /* CSE for XLOAD depends on the type, but not on the IRXLOAD_* flags. */
563 if (IR(ref)->op1 == fins->op1 && irt_sametype(IR(ref)->t, fins->t))
564 return ref;
565 ref = IR(ref)->prev;
566 }
567 return lj_ir_emit(J);
568}
569
526/* -- Forwarding of lj_tab_len -------------------------------------------- */ 570/* -- Forwarding of lj_tab_len -------------------------------------------- */
527 571
528/* This is rather simplistic right now, but better than nothing. */ 572/* This is rather simplistic right now, but better than nothing. */