Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2015-06-10 16:15:41 +02:00
commit 5081e38031

View File

@ -205,7 +205,6 @@ typedef struct NarrowConv {
jit_State *J; /* JIT compiler state. */ jit_State *J; /* JIT compiler state. */
NarrowIns *sp; /* Current stack pointer. */ NarrowIns *sp; /* Current stack pointer. */
NarrowIns *maxsp; /* Maximum stack pointer minus redzone. */ NarrowIns *maxsp; /* Maximum stack pointer minus redzone. */
int lim; /* Limit on the number of emitted conversions. */
IRRef mode; /* Conversion mode (IRCONV_*). */ IRRef mode; /* Conversion mode (IRCONV_*). */
IRType t; /* Destination type: IRT_INT or IRT_I64. */ IRType t; /* Destination type: IRT_INT or IRT_I64. */
NarrowIns stack[NARROW_MAX_STACK]; /* Stack holding stack-machine code. */ NarrowIns stack[NARROW_MAX_STACK]; /* Stack holding stack-machine code. */
@ -342,7 +341,7 @@ static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth)
NarrowIns *savesp = nc->sp; NarrowIns *savesp = nc->sp;
int count = narrow_conv_backprop(nc, ir->op1, depth); int count = narrow_conv_backprop(nc, ir->op1, depth);
count += narrow_conv_backprop(nc, ir->op2, depth); count += narrow_conv_backprop(nc, ir->op2, depth);
if (count <= nc->lim) { /* Limit total number of conversions. */ if (count <= 1) { /* Limit total number of conversions. */
*nc->sp++ = NARROWINS(IRT(ir->o, nc->t), ref); *nc->sp++ = NARROWINS(IRT(ir->o, nc->t), ref);
return count; return count;
} }
@ -414,12 +413,10 @@ TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J)
nc.t = irt_type(fins->t); nc.t = irt_type(fins->t);
if (fins->o == IR_TOBIT) { if (fins->o == IR_TOBIT) {
nc.mode = IRCONV_TOBIT; /* Used only in the backpropagation cache. */ nc.mode = IRCONV_TOBIT; /* Used only in the backpropagation cache. */
nc.lim = 2; /* TOBIT can use a more optimistic rule. */
} else { } else {
nc.mode = fins->op2; nc.mode = fins->op2;
nc.lim = 1;
} }
if (narrow_conv_backprop(&nc, fins->op1, 0) <= nc.lim) if (narrow_conv_backprop(&nc, fins->op1, 0) <= 1)
return narrow_conv_emit(J, &nc); return narrow_conv_emit(J, &nc);
} }
return NEXTFOLD; return NEXTFOLD;