Skip to content

Commit

Permalink
[BE] fix? resolve loops (OpenModelica#12186)
Browse files Browse the repository at this point in the history
- take any equation if no order is enforced when sorting loop equations
 - (can occur because previous steps removed actual loop dependencies)

   Co-authored-by: phannebohm <phannebohm@hsbi.de>
  • Loading branch information
kabdelhak committed Apr 3, 2024
1 parent cf069db commit cf32d46
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions OMCompiler/Compiler/BackEnd/ResolveLoops.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1330,18 +1330,20 @@ algorithm
equation
then
listReverse(sortLoopIn);
case(_,_,_,start::rest)
equation
vars = arrayGet(m,start);
varEqs = List.map1(vars,Array.getIndexFirst,mT);
eqs = List.flatten(varEqs);
eqs = List.unique(eqs);
eqs = List.intersectionOnTrue(eqs,loopIn,intEq);
next = listHead(eqs);
rest = List.deleteMember(loopIn,next);
rest = sortLoop(rest,m,mT,next::sortLoopIn);
then
rest;
case(_,_,_,start::_)
algorithm
vars := arrayGet(m,start);
varEqs := List.map1(vars,Array.getIndexFirst,mT);
eqs := List.flatten(varEqs);
eqs := List.unique(eqs);
eqs := List.intersectionOnTrue(eqs,loopIn,intEq);
if listEmpty(eqs) then
next := List.first(loopIn);
else
next := List.first(eqs);
end if;
rest := List.deleteMember(loopIn,next);
then sortLoop(rest,m,mT,next::sortLoopIn);
end matchcontinue;
end sortLoop;

Expand Down Expand Up @@ -1814,6 +1816,11 @@ algorithm
// constant
then
(false,false);
case(DAE.ICONST(),_)
equation
// constant
then
(false,false);
else
equation
print("add a case to expIsCref:"+ExpressionDump.printExpStr(expIn)+"\n");
Expand Down

0 comments on commit cf32d46

Please sign in to comment.