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

Commit 8167b9d

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Partially revert 8fcf925.
- The equations shouldn't be reverted when replacing an if-equation with its first branch. - Disable simplification of for-loops over a one-sized range, it causes some models to become unbalanced for unknown reasons. Belonging to [master]: - #2905
1 parent be0943f commit 8167b9d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Compiler/NFFrontEnd/NFSimplifyModel.mo

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,14 @@ algorithm
271271
ty := Expression.typeOf(e);
272272
dim := Type.nthDimension(ty, 1);
273273

274-
if Dimension.isOne(dim) then
275-
e := Expression.applySubscript(Subscript.INDEX(Expression.INTEGER(1)), e);
276-
body := Statement.mapExpList(stmt.body,
277-
function Expression.replaceIterator(iterator = stmt.iterator, iteratorValue = e));
278-
body := simplifyStatements(body);
279-
statements := listAppend(body, statements);
280-
elseif not Dimension.isZero(dim) then
274+
//if Dimension.isOne(dim) then
275+
// e := Expression.applySubscript(Subscript.INDEX(Expression.INTEGER(1)), e);
276+
// body := Statement.mapExpList(stmt.body,
277+
// function Expression.replaceIterator(iterator = stmt.iterator, iteratorValue = e));
278+
// body := simplifyStatements(body);
279+
// statements := listAppend(listReverse(body), statements);
280+
//elseif not Dimension.isZero(dim) then
281+
if not Dimension.isZero(dim) then
281282
stmt.range := SOME(SimplifyExp.simplify(e));
282283
stmt.body := simplifyStatements(stmt.body);
283284
statements := stmt :: statements;
@@ -375,7 +376,7 @@ algorithm
375376
if Expression.isTrue(cond) then
376377
if listEmpty(accum) then
377378
// If it's the first branch, remove the if and keep only the branch body.
378-
elements := listAppend(listReverse(simplifyEquations(body)), elements);
379+
elements := listAppend(simplifyEquations(body), elements);
379380
return;
380381
else
381382
// Otherwise just discard the rest of the branches.

0 commit comments

Comments
 (0)