Propagate non aliasing initializers to compile time constants
This commit is contained in:
parent
52db653ec1
commit
2310416c46
|
@ -275,15 +275,23 @@ 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)
|
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;
|
Expression* cexp = exp->mDecValue->mValue;
|
||||||
if (cexp->mType == EX_CONSTANT &&
|
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->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->mType = EX_CONSTANT;
|
||||||
exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType);
|
exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
else if (exp->mDecValue->mBase->mType == DT_TYPE_STRUCT)
|
||||||
|
{
|
||||||
|
exp->mDecValue->mBase = exp->mDecValue->mBase->ToConstType();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReplaceGlobalConst(exp->mLeft))
|
if (ReplaceGlobalConst(exp->mLeft))
|
||||||
|
|
Loading…
Reference in New Issue