Skip to content

Commit

Permalink
Let the CSE look into if-conditions
Browse files Browse the repository at this point in the history
If-conditions always execute, so we can consider them for CSE
optimizations. This improves some Media models by a factor of 10x since
the function calls are called inside an algebraic loop (multiple times,
although this matters little relative to moving the call outside of the
loop).

This fixes an issue with performance discovered in ticket:4423.

Belonging to [master]:
  - OpenModelica/OMCompiler#2094
  - OpenModelica/OpenModelica-testsuite#812
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jan 4, 2018
1 parent d1104ce commit ee6b27b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Compiler/BackEnd/CommonSubExpression.mo
Expand Up @@ -852,7 +852,12 @@ algorithm
DAE.ComponentRef cr;

case DAE.IFEXP()
then false;
algorithm
(_, outTuple) := Expression.traverseExpTopDown(inExp.expCond, wrapFunctionCalls_analysis3, inTuple);
// TODO: We should also have analyzed all of the branches; if a call is present in all branches we can perform CSE. But the data structure is a hashtable and we would need to use immutable types...
cont := false;
return;
then fail();

// TODO: split up skip cases
case _
Expand Down

0 comments on commit ee6b27b

Please sign in to comment.