Skip to content

Commit

Permalink
Avoid expanding equations
Browse files Browse the repository at this point in the history
- In RemoveSimpleEquations, check if simplifying a vector equation after
  expanding it causes simplify to perform any changes. If no change
  occurs, it is unlinkely that removeSimpleEquations will work on the
  equation, so discard the expansion.

This fixes the performance problem reported in ticket:4453
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jul 25, 2017
1 parent 169fa51 commit 2933df6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -537,7 +537,7 @@ algorithm
simpleContainer := List.listArrayReverse(simpleContainerIn);
// collect and handle sets
(vars, eqnslst, shared, repl) := handleSets(arrayLength(simpleContainer), 1, simpleContainer, iMT, iUnreplaceable, iVars, iEqnslst, ishared, iRepl);
//BackendVarTransform.dumpReplacements(repl);
//BackendVarTransform.dumpReplacements(repl);

// perform replacements and try again
(eqnslst, b1) := BackendVarTransform.replaceEquations(eqnslst, repl, SOME(BackendVarTransform.skipPreChangeEdgeOperator));
Expand Down Expand Up @@ -1154,8 +1154,8 @@ algorithm
ds := Expression.dimensionsSizes(dims);
subslst := List.map(ds, Expression.dimensionSizeSubscripts);
subslst := Expression.rangesToSubscripts(subslst);
elst1 := List.map1r(subslst, Expression.applyExpSubscripts, lhs);
elst2 := List.map1r(subslst, Expression.applyExpSubscripts, rhs);
(elst1,true) := List.mapFold(subslst, function Expression.applyExpSubscriptsFoldCheckSimplify(exp=lhs), false);
(elst2,true) := List.mapFold(subslst, function Expression.applyExpSubscriptsFoldCheckSimplify(exp=rhs), false) "Do not expand equation if it doesn't help with anything... Like x=f(...); => x[1]=f()[1], ..., x[n]=f()[n]";
outTpl := List.threadFold2(elst1, elst2, simpleEquationAcausal, eqnAttributes, true, inTpl);
end simpleArrayEquationAcausal;

Expand Down

0 comments on commit 2933df6

Please sign in to comment.