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

Commit 1fd2008

Browse files
vwaurichOpenModelica-Hudson
authored andcommitted
simpify r1+r2+cr ->r3+cr
Belonging to [master]: - #2024
1 parent a4417ed commit 1fd2008

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Compiler/FrontEnd/ExpressionSimplify.mo

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,6 +4081,21 @@ algorithm
40814081
checkZeroLengthArrayOp(oper);
40824082
then e1;
40834083

4084+
// Look for empty arrays
4085+
case (_,DAE.ADD(),DAE.RCONST(r),DAE.BINARY(DAE.RCONST(r1),DAE.SUB(ty=ty),DAE.CREF(componentRef=cr1, ty=ty2)),_,_)
4086+
equation
4087+
//print(" case55555 ");
4088+
//print("\n"+ExpressionDump.dumpExpStr(origExp,1)+"\n");
4089+
e1 = DAE.BINARY(DAE.RCONST(realAdd(r,r1)),DAE.SUB(ty),DAE.CREF(cr1, ty2));
4090+
//print("\nMAKE "+ExpressionDump.dumpExpStr(e1,1)+"\n");
4091+
then e1;
4092+
4093+
// a*(b^(-e)) => a/(b^e)
4094+
case (_,DAE.ADD(),e1,DAE.BINARY(exp1 = e2,operator = DAE.POW(ty = ty2),exp2 = DAE.UNARY(exp=e3,operator=DAE.UMINUS())),_,_)
4095+
equation
4096+
res = DAE.BINARY(e1,DAE.DIV(ty2),DAE.BINARY(e2,DAE.POW(ty2),e3));
4097+
then res;
4098+
40844099
// a*(b^(-e)) => a/(b^e)
40854100
case (_,DAE.MUL(),e1,DAE.BINARY(exp1 = e2,operator = DAE.POW(ty = ty2),exp2 = DAE.UNARY(exp=e3,operator=DAE.UMINUS())),_,_)
40864101
equation

0 commit comments

Comments
 (0)