Optimization of small integer floating point constants.
[COMPILER] * OPT: Optimization of small integer floating point constants. [INTEGER] * OPT: Optimization of small integer floating point constants. [GB.JIT] * OPT: Optimization of small integer floating point constants.
This commit is contained in:
parent
f749ce2030
commit
1004b39078
8 changed files with 47 additions and 3 deletions
|
@ -184,6 +184,10 @@ static void push_number(int index)
|
|||
{
|
||||
CODE_push_number(number.ival);
|
||||
}
|
||||
else if (number.type == T_FLOAT && COMP_version >= 0x03180000 && number.dval == (double)(int)number.dval && number.dval >= -128 && number.dval <= 127)
|
||||
{
|
||||
CODE_push_float(number.dval);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLEAR(&decl);
|
||||
|
|
|
@ -604,7 +604,7 @@ void EXEC_loop(void)
|
|||
/* F4 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F5 PUSH QUICK */ &&_PUSH_VARIABLE,
|
||||
/* F6 PUSH QUICK */ &&_POP_VARIABLE,
|
||||
/* F7 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F7 PUSH QUICK */ &&_PUSH_FLOAT,
|
||||
/* F8 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F9 PUSH QUICK */ &&_POP_LOCAL_NOREF,
|
||||
/* FA PUSH QUICK */ &&_POP_PARAM_NOREF,
|
||||
|
@ -642,7 +642,7 @@ void EXEC_loop(void)
|
|||
/* F4 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F5 PUSH QUICK */ &&_PUSH_VARIABLE,
|
||||
/* F6 PUSH QUICK */ &&_POP_VARIABLE,
|
||||
/* F7 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F7 PUSH QUICK */ &&_PUSH_FLOAT,
|
||||
/* F8 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F9 PUSH QUICK */ &&_POP_LOCAL_NOREF,
|
||||
/* FA PUSH QUICK */ &&_POP_PARAM_NOREF,
|
||||
|
@ -1902,6 +1902,15 @@ _PUSH_QUICK:
|
|||
|
||||
/*-----------------------------------------------*/
|
||||
|
||||
_PUSH_FLOAT:
|
||||
|
||||
SP->type = T_FLOAT;
|
||||
SP->_float.value = GET_XX();
|
||||
SP++;
|
||||
goto _NEXT;
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
|
||||
_ADD_QUICK:
|
||||
|
||||
{
|
||||
|
|
|
@ -83,6 +83,10 @@ static void push_number(int index)
|
|||
{
|
||||
CODE_push_number(number.ival);
|
||||
}
|
||||
else if (number.type == T_FLOAT && number.dval == (double)(int)number.dval && number.dval >= -128 && number.dval <= 127)
|
||||
{
|
||||
CODE_push_float(number.dval);
|
||||
}
|
||||
else
|
||||
{
|
||||
cst.type = number.type;
|
||||
|
|
|
@ -2875,7 +2875,7 @@ bool JIT_translate_body(FUNCTION *func, int ind)
|
|||
/* F4 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F5 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F6 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F7 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F7 PUSH QUICK */ &&_PUSH_FLOAT,
|
||||
/* F8 PUSH QUICK */ &&_PUSH_QUICK,
|
||||
/* F9 PUSH QUICK */ &&_POP_LOCAL_NOREF,
|
||||
/* FA PUSH QUICK */ &&_POP_PARAM_NOREF,
|
||||
|
@ -3033,6 +3033,14 @@ _PUSH_QUICK:
|
|||
push(T_INTEGER, "%d", GET_XXX());
|
||||
goto _MAIN;
|
||||
|
||||
_PUSH_FLOAT:
|
||||
|
||||
if (class->not_3_18)
|
||||
goto _PUSH_QUICK;
|
||||
|
||||
push(T_FLOAT, "%d", GET_XX());
|
||||
goto _MAIN;
|
||||
|
||||
_PUSH_SHORT:
|
||||
|
||||
push(T_INTEGER, "%d", (short)PC[0]);
|
||||
|
|
|
@ -121,6 +121,7 @@ void CODE_ignore_next_stack_usage(void);
|
|||
void CODE_dump(PCODE *code, int count);
|
||||
|
||||
void CODE_push_number(int value);
|
||||
void CODE_push_float(int value);
|
||||
void CODE_push_const(ushort value);
|
||||
|
||||
void CODE_push_local_ref(short num, bool noref);
|
||||
|
|
|
@ -455,6 +455,15 @@ void CODE_push_number(int value)
|
|||
}
|
||||
}
|
||||
|
||||
void CODE_push_float(int value)
|
||||
{
|
||||
LAST_CODE;
|
||||
|
||||
use_stack(1);
|
||||
|
||||
write_ZZxx(C_PUSH_FLOAT, value);
|
||||
}
|
||||
|
||||
|
||||
void CODE_push_const(ushort value)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define C_PUSH_PARAM_NOREF 0xF200
|
||||
#define C_PUSH_VARIABLE 0xF500
|
||||
#define C_POP_VARIABLE 0xF600
|
||||
#define C_PUSH_FLOAT 0xF700
|
||||
#define C_POP_LOCAL_NOREF 0xF900
|
||||
#define C_POP_PARAM_NOREF 0xFA00
|
||||
#define C_POP_LOCAL_FAST 0xFB00
|
||||
|
|
|
@ -172,6 +172,10 @@ short PCODE_dump(FILE *out, ushort addr, PCODE *code)
|
|||
fprintf(out, "POP PARAM FAST %d", (char)(op & 0xFF));
|
||||
break;
|
||||
|
||||
case C_PUSH_FLOAT:
|
||||
fprintf(out, "PUSH FLOAT %d", (char)(op & 0xFF));
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(out, "PUSH QUICK %d", (short)value);
|
||||
}
|
||||
|
@ -262,6 +266,10 @@ short PCODE_dump(FILE *out, ushort addr, PCODE *code)
|
|||
fprintf(out, "POP PARAM FAST %d", (char)(op & 0xFF));
|
||||
break;
|
||||
|
||||
case C_PUSH_FLOAT:
|
||||
fprintf(out, "PUSH FLOAT %d", (char)(op & 0xFF));
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(out, "PUSH QUICK %d", (short)value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue