Free 14 bytecode slots by using 'ADD QUICK' for numbers between -255 and 255 only.

[COMPILER]
* NEW: Free 14 bytecode slots by using 'ADD QUICK' for numbers between -255 and 255 only.
This commit is contained in:
Benoît Minisini 2022-09-12 15:02:39 +02:00
parent c2005ad919
commit 1cec6f118b

View file

@ -899,27 +899,30 @@ void CODE_op(short op, short subcode, short nparam, bool fixed)
printf("ADD QUICK %d\n", value); printf("ADD QUICK %d\n", value);
#endif #endif
*last_code = C_ADD_QUICK | (value & 0x0FFF); if (COMP_version < 0x03180000 || (value >= -255 && value <= 255))
use_stack(1 - nparam);
// Now, look if we are PUSH QUICK then ADD QUICK
last_code = get_last_code2();
if (last_code && ((*last_code & 0xF000) == C_PUSH_QUICK))
{ {
value2 = *last_code & 0xFFF; *last_code = C_ADD_QUICK | (value & 0x0FFF);
if (value2 >= 0x800) value2 |= 0xF000;
value += value2;
if (value >= -2048L && value < 2048L) use_stack(1 - nparam);
// Now, look if we are PUSH QUICK then ADD QUICK
last_code = get_last_code2();
if (last_code && ((*last_code & 0xF000) == C_PUSH_QUICK))
{ {
*last_code = C_PUSH_QUICK | (value & 0x0FFF); value2 = *last_code & 0xFFF;
CODE_undo(); if (value2 >= 0x800) value2 |= 0xF000;
} value += value2;
}
return; if (value >= -2048L && value < 2048L)
{
*last_code = C_PUSH_QUICK | (value & 0x0FFF);
CODE_undo();
}
}
return;
}
} }
} }