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

Commit

Permalink
do simplification of "a and not a" to false only for boolean type
Browse files Browse the repository at this point in the history
same for "a or not a" to true

Belonging to [master]:
  - #2035
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Nov 19, 2017
1 parent ce3522c commit add36ff
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -4768,33 +4768,27 @@ protected function simplifyLBinary
algorithm
outExp := match (origExp,inOperator2,inExp3,inExp4)
local
DAE.Exp e1_1,e3,e,e1,e2,e4,e5,e6,res,one;
Operator oper, op1 ,op2, op3;
Type ty,ty2,tp,tp2,ty1;
list<DAE.Exp> exp_lst,exp_lst_1;
DAE.ComponentRef cr1,cr2;
Boolean b,b1,b2;
Real r;
Option<DAE.Exp> oexp;
DAE.Exp e1,e2;
Boolean b;

// fix for PNLib where "{} and not {}" is evaluated
case (_,_,DAE.ARRAY(array={}),_)
then origExp;
case (_,_,_,DAE.ARRAY(array={}))
then origExp;
// a AND not a -> false
case (_,DAE.AND(_),e1,DAE.LUNARY(DAE.NOT(_),e2))
case (_,DAE.AND(DAE.T_BOOL()),e1,DAE.LUNARY(DAE.NOT(_),e2))
guard Expression.expEqual(e1, e2)
then DAE.BCONST(false);
case (_,DAE.AND(_),DAE.LUNARY(DAE.NOT(_),e1),e2)
case (_,DAE.AND(DAE.T_BOOL()),DAE.LUNARY(DAE.NOT(_),e1),e2)
guard Expression.expEqual(e1, e2)
then DAE.BCONST(false);

// a OR not a -> true
case (_,DAE.OR(_),e1,DAE.LUNARY(DAE.NOT(_),e2))
case (_,DAE.OR(DAE.T_BOOL()),e1,DAE.LUNARY(DAE.NOT(_),e2))
guard Expression.expEqual(e1, e2)
then DAE.BCONST(true);
case (_,DAE.OR(_),DAE.LUNARY(DAE.NOT(_),e1),e2)
case (_,DAE.OR(DAE.T_BOOL()),DAE.LUNARY(DAE.NOT(_),e1),e2)
guard Expression.expEqual(e1, e2)
then DAE.BCONST(true);

Expand Down

0 comments on commit add36ff

Please sign in to comment.