Propagate non aliasing initializers to compile time constants
This commit is contained in:
parent
52db653ec1
commit
2310416c46
|
@ -275,14 +275,22 @@ bool GlobalOptimizer::ReplaceGlobalConst(Expression* exp)
|
|||
{
|
||||
if (exp->mType == EX_VARIABLE && (exp->mDecValue->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(exp->mDecValue->mOptFlags & (OPTF_VAR_MODIFIED | OPTF_VAR_ADDRESS)) && exp->mDecValue->mValue)
|
||||
{
|
||||
|
||||
Expression* cexp = exp->mDecValue->mValue;
|
||||
if (cexp->mType == EX_CONSTANT &&
|
||||
(cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER ||
|
||||
cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT))
|
||||
if (cexp->mType == EX_CONSTANT)
|
||||
{
|
||||
exp->mType = EX_CONSTANT;
|
||||
exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType);
|
||||
changed = true;
|
||||
|
||||
if (cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER ||
|
||||
cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT)
|
||||
{
|
||||
exp->mType = EX_CONSTANT;
|
||||
exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType);
|
||||
changed = true;
|
||||
}
|
||||
else if (exp->mDecValue->mBase->mType == DT_TYPE_STRUCT)
|
||||
{
|
||||
exp->mDecValue->mBase = exp->mDecValue->mBase->ToConstType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue