Optimize the compilation of floating-point global constants being actually an integer between -128 and 127.
[COMPILER] * OPT: Optimize the compilation of floating-point global constants being actually an integer between -128 and 127.
This commit is contained in:
parent
542d72d39d
commit
49be8a880e
2 changed files with 9 additions and 2 deletions
|
@ -776,7 +776,8 @@ void TRANS_get_constant_value(TRANS_DECL *decl)
|
|||
|
||||
value = *JOB->current++;
|
||||
index = PATTERN_index(value);
|
||||
|
||||
decl->is_integer = FALSE;
|
||||
|
||||
if (PATTERN_is_integer(value))
|
||||
{
|
||||
decl->is_integer = TRUE;
|
||||
|
@ -790,7 +791,11 @@ void TRANS_get_constant_value(TRANS_DECL *decl)
|
|||
if (type == T_SINGLE && !finite((float)number.dval))
|
||||
THROW("Out of range");
|
||||
|
||||
decl->is_integer = FALSE;
|
||||
if (COMP_version >= 0x03180000 && number.dval == (double)(int)number.dval && number.dval >= -128 && number.dval <= 127)
|
||||
{
|
||||
decl->is_integer = TRUE;
|
||||
index = (int)number.dval;
|
||||
}
|
||||
}
|
||||
|
||||
decl->value = index;
|
||||
|
|
|
@ -313,6 +313,8 @@ static void trans_identifier(int index, bool point, PATTERN next)
|
|||
CODE_push_boolean(constant->value);
|
||||
else if (type == T_INTEGER)
|
||||
CODE_push_number(constant->value);
|
||||
else if (constant->is_integer)
|
||||
CODE_push_float(constant->value);
|
||||
else
|
||||
CODE_push_const(sym->global.value);
|
||||
|
||||
|
|
Loading…
Reference in a new issue