comparison lwasm/insn_indexed.c @ 464:9134f6426c57

Fix think-o in PCR optimization fix from previous commit Need to make sure we don't encode a larger offset size than needed if we guess a 16 bit offset with "pretend max" in effect.
author William Astle <lost@l-w.ca>
date Wed, 28 Feb 2018 23:15:35 -0700
parents 42be9eec7935
children 7370a67caf7e
comparison
equal deleted inserted replaced
463:42be9eec7935 464:9134f6426c57
467 lwasm_reduce_expr(as, e2); 467 lwasm_reduce_expr(as, e2);
468 // l -> len += 1; 468 // l -> len += 1;
469 // e3 = lw_expr_copy(e); 469 // e3 = lw_expr_copy(e);
470 // lwasm_reduce_expr(as, e3); 470 // lwasm_reduce_expr(as, e3);
471 l -> len = -1; 471 l -> len = -1;
472 if (!lw_expr_istype(e2, lw_expr_type_int))
473 {
474 v = as -> pretendmax;
475 as -> pretendmax = 1;
476 lwasm_reduce_expr(as, e2);
477 as -> pretendmax = v;
478 }
479 if (lw_expr_istype(e2, lw_expr_type_int)) 472 if (lw_expr_istype(e2, lw_expr_type_int))
480 { 473 {
481 v = lw_expr_intval(e2); 474 v = lw_expr_intval(e2);
482 // we have a reducible expression here which depends on 475 // we have a reducible expression here which depends on
483 // the size of this instruction 476 // the size of this instruction
576 l -> pb = pb; 569 l -> pb = pb;
577 lw_expr_destroy(e2); 570 lw_expr_destroy(e2);
578 return; 571 return;
579 } 572 }
580 } 573 }
574 else
575 {
576 if ((l -> pb & 0x07) == 5 || (l -> pb & 0x07) == 6)
577 {
578 v = as -> pretendmax;
579 as -> pretendmax = 1;
580 lwasm_reduce_expr(as, e2);
581 as -> pretendmax = v;
582 v = lw_expr_intval(e2);
583 if (v >= -128 || v <= 127)
584 {
585 l -> lint = 1;
586 pb = (l -> pb & 0x80) ? 0x9C : 0x8C;
587 return;
588 }
589 }
590 }
581 lw_expr_destroy(e2); 591 lw_expr_destroy(e2);
582 } 592 }
583 593
584 if (lw_expr_istype(e, lw_expr_type_int)) 594 if (lw_expr_istype(e, lw_expr_type_int))
585 { 595 {