Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Dont expand algorithm when counting the size after removeSimpleEquations
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Oct 27, 2016
1 parent 7def99e commit ae27c2b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1691,9 +1691,10 @@ algorithm
list<DAE.Exp> expl,expl1,expl2;
BackendDAE.WhenEquation whenEqn,whenEqn1;
DAE.ElementSource source;
Boolean b1,b2,b3;
Boolean b1,b2,b3, hasArrayCref;
list<Integer> dimSize;
DAE.Algorithm alg;
list<DAE.ComponentRef> crefs;
list<DAE.Statement> stmts,stmts1;
list<Boolean> blst;
list<BackendDAE.Equation> eqns;
Expand Down Expand Up @@ -1736,6 +1737,11 @@ algorithm

case (BackendDAE.ALGORITHM(size=size, alg=alg as DAE.ALGORITHM_STMTS(statementLst=stmts), source=source, expand=crefExpand, attr=eqAttr), repl, _, _, _)
equation
(crefs,_) = Expression.extractUniqueCrefsFromStatmentS(stmts);
// if there is no need for expanding the original equation, the replaced one shouldn't either
hasArrayCref = List.exist(crefs,ComponentReference.isArrayElement);
crefExpand = if hasArrayCref then crefExpand else DAE.NOT_EXPAND();

(stmts1,true) = replaceStatementLst(stmts,repl,inFuncTypeExpExpToBooleanOption,{},false);
alg = DAE.ALGORITHM_STMTS(stmts1);
// if all statements are removed, remove the whole algorithm
Expand Down
49 changes: 45 additions & 4 deletions Compiler/FrontEnd/Expression.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6171,19 +6171,60 @@ algorithm
(olcrefs,orcrefs) := match(inStmt)
local
Exp exp1,exp2;
case DAE.STMT_ASSERT(cond = exp1)
list<DAE.Exp> expLst;
list<DAE.Statement> stmtLst;

case DAE.STMT_ASSIGN(exp1 = exp1, exp = exp2)
equation
orcrefs = extractCrefsFromExpDerPreStart(exp1);
olcrefs = extractCrefsFromExpDerPreStart(exp1);
orcrefs = extractCrefsFromExpDerPreStart(exp2);
then
({},orcrefs);
(olcrefs,orcrefs);

case DAE.STMT_ASSIGN(exp1 = exp1, exp = exp2)
case DAE.STMT_TUPLE_ASSIGN(expExpLst = expLst, exp = exp2)
equation
olcrefs = List.flatten(List.map(expLst, extractCrefsFromExpDerPreStart));
orcrefs = extractCrefsFromExpDerPreStart(exp2);
then
(olcrefs,orcrefs);

case DAE.STMT_ASSIGN_ARR(lhs = exp1, exp = exp2)
equation
olcrefs = extractCrefsFromExpDerPreStart(exp1);
orcrefs = extractCrefsFromExpDerPreStart(exp2);
then
(olcrefs,orcrefs);

case DAE.STMT_IF(statementLst = stmtLst)
equation
(olcrefs,orcrefs) = extractUniqueCrefsFromStatmentS(stmtLst);
then
(olcrefs,orcrefs);

case DAE.STMT_FOR(statementLst = stmtLst)
equation
(olcrefs,orcrefs) = extractUniqueCrefsFromStatmentS(stmtLst);
then
(olcrefs,orcrefs);

case DAE.STMT_WHILE(statementLst = stmtLst)
equation
(olcrefs,orcrefs) = extractUniqueCrefsFromStatmentS(stmtLst);
then
(olcrefs,orcrefs);

case DAE.STMT_WHEN(statementLst = stmtLst)
equation
(olcrefs,orcrefs) = extractUniqueCrefsFromStatmentS(stmtLst);
then
(olcrefs,orcrefs);

case DAE.STMT_ASSERT(cond = exp1)
equation
orcrefs = extractCrefsFromExpDerPreStart(exp1);
then
({},orcrefs);

else ({},{});

end match;
Expand Down

0 comments on commit ae27c2b

Please sign in to comment.