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

Commit

Permalink
Do not get algorithm crefs that will be discarded
Browse files Browse the repository at this point in the history
This fixes the scaling issue of evaluateParameters.

ticket:4552

Belonging to [master]:
  - #1914
  • Loading branch information
ptaeuber authored and OpenModelica-Hudson committed Oct 17, 2017
1 parent 702e338 commit 73e4cc5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ algorithm

case (BackendDAE.ALGORITHM(size=size, alg=DAE.ALGORITHM_STMTS(statementLst=stmts), source=source, expand=crefExpand, attr=eqAttr), repl, _, _, _)
equation
(crefs,_) = Expression.extractUniqueCrefsFromStatmentS(stmts);
crefs = Expression.getLhsCrefsFromStatements(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();
Expand Down
62 changes: 62 additions & 0 deletions Compiler/FrontEnd/Expression.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6260,6 +6260,68 @@ algorithm
end match;
end extractCrefsStatment;

public function getLhsCrefsFromStatements "Extracts all lhs crefs from Statements.
author: ptaeuber"
input list<DAE.Statement> inStmts;
output list<DAE.ComponentRef> lhsCrefs;
protected
list<list<DAE.ComponentRef>> lhsCrefsLst;
algorithm
lhsCrefsLst := List.map(inStmts,getLhsCrefsFromStatement);
lhsCrefs := List.flatten(lhsCrefsLst);
end getLhsCrefsFromStatements;

protected function getLhsCrefsFromStatement "Extracts all lhs crefs from a statement.
author: ptaeuber"
input DAE.Statement inStmt;
output list<DAE.ComponentRef> lhsCrefs;
algorithm
lhsCrefs := match(inStmt)
local
Exp exp1,exp2;
list<DAE.Exp> expLst;
list<DAE.Statement> stmtLst;

case DAE.STMT_ASSIGN(exp1 = exp1)
equation
lhsCrefs = extractCrefsFromExpDerPreStart(exp1);
then lhsCrefs;

case DAE.STMT_TUPLE_ASSIGN(expExpLst = expLst)
equation
lhsCrefs = List.flatten(List.map(expLst, extractCrefsFromExpDerPreStart));
then lhsCrefs;

case DAE.STMT_ASSIGN_ARR(lhs = exp1)
equation
lhsCrefs = extractCrefsFromExpDerPreStart(exp1);
then lhsCrefs;

case DAE.STMT_IF(statementLst = stmtLst)
equation
lhsCrefs = getLhsCrefsFromStatements(stmtLst);
then lhsCrefs;

case DAE.STMT_FOR(statementLst = stmtLst)
equation
lhsCrefs = getLhsCrefsFromStatements(stmtLst);
then lhsCrefs;

case DAE.STMT_WHILE(statementLst = stmtLst)
equation
lhsCrefs = getLhsCrefsFromStatements(stmtLst);
then lhsCrefs;

case DAE.STMT_WHEN(statementLst = stmtLst)
equation
lhsCrefs = getLhsCrefsFromStatements(stmtLst);
then lhsCrefs;

else {};

end match;
end getLhsCrefsFromStatement;

public function expHasInitial "
returns true if the expression contains any initial() call"
input DAE.Exp exp;
Expand Down

0 comments on commit 73e4cc5

Please sign in to comment.