Skip to content

Commit

Permalink
- Added ExpressionSimplify rules
Browse files Browse the repository at this point in the history
  - true AND e => e
  - false OR e => e


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7364 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 12, 2010
1 parent 94ae72b commit c17fa42
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Compiler/ExpressionSimplify.mo
Expand Up @@ -3187,7 +3187,7 @@ algorithm
then
res;

// relation: cr1 == cr2, where cr1 and cr2 are the same
// relation: cr1 == cr2, where cr1 and cr2 are the same
case(_,DAE.EQUAL(_),DAE.CREF(cr1,_),DAE.CREF(cr2,_))
equation
true = ComponentReference.crefEqual(cr1,cr2);
Expand All @@ -3201,6 +3201,15 @@ algorithm
then
DAE.BCONST(false);

// true AND e => e
// TODO: Check if false AND e => false is ok, or if zero-crossing screw us over
case (_,DAE.AND(),DAE.BCONST(true),e) then e;
case (_,DAE.AND(),e,DAE.BCONST(true)) then e;
// false OR e => e
// TODO: Check if true or e => true is ok, or if zero-crossing screw us over
case (_,DAE.OR(),DAE.BCONST(false),e) then e;
case (_,DAE.OR(),e,DAE.BCONST(false)) then e;

// nothing else to simplify
case (e,_,_,_) then e;
end matchcontinue;
Expand Down

0 comments on commit c17fa42

Please sign in to comment.