Skip to content

Commit

Permalink
Use isConstValue instead of isConst for an 18 second testsuite boost
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17957 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 31, 2013
1 parent a486e41 commit 00ebb6b
Showing 1 changed file with 21 additions and 68 deletions.
89 changes: 21 additions & 68 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3271,149 +3271,103 @@ algorithm
Option<DAE.Exp> oexp;
DAE.Type ty;

case (DAE.ADD(ty = _),DAE.RANGE(ty=ty,start = exp1,step=oexp,stop=exp2),_)
equation
exp1 = simplifyBinaryConst(inOperator1, exp1, inExp3);
exp2 = simplifyBinaryConst(inOperator1, exp2, inExp3);
then
DAE.RANGE(ty,exp1,oexp,exp2);

case (DAE.ADD(ty = _),_,DAE.RANGE(ty=ty,start = exp1,step=oexp,stop=exp2))
equation
exp1 = simplifyBinaryConst(inOperator1, inExp2, exp1);
exp2 = simplifyBinaryConst(inOperator1, inExp2, exp2);
then
DAE.RANGE(ty,exp1,oexp,exp2);

case (DAE.SUB(ty = _),DAE.RANGE(ty=ty,start = exp1,step=oexp,stop=exp2),_)
equation
exp1 = simplifyBinaryConst(inOperator1, exp1, inExp3);
exp2 = simplifyBinaryConst(inOperator1, exp2, inExp3);
then
DAE.RANGE(ty,exp1,oexp,exp2);

case (DAE.SUB(ty = _),_,DAE.RANGE(ty=ty,start = exp1,step=oexp,stop=exp2))
equation
exp1 = simplifyBinaryConst(inOperator1, inExp2, exp1);
exp2 = simplifyBinaryConst(inOperator1, inExp2, exp2);
then
DAE.RANGE(ty,exp1,oexp,exp2);

case (DAE.ADD(ty = _),DAE.ICONST(integer = ie1),DAE.ICONST(integer = ie2))
equation
val = safeIntOp(ie1,ie2,ExpressionSimplifyTypes.ADDOP());
then
val;
then val;

case (DAE.ADD(ty = _),DAE.RCONST(real = re1),DAE.RCONST(real = re2))
equation
re3 = re1 +. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.ADD(ty = _),DAE.RCONST(real = re1),DAE.ICONST(integer = ie2))
equation
e2_1 = intReal(ie2);
re3 = re1 +. e2_1;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.ADD(ty = _),DAE.ICONST(integer = ie1),DAE.RCONST(real = re2))
equation
e1_1 = intReal(ie1);
re3 = e1_1 +. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.ADD(ty = _),DAE.SCONST(string = s1),DAE.SCONST(string = s2))
equation
str = s1 +& s2;
then
DAE.SCONST(str);
then DAE.SCONST(str);

case (DAE.SUB(ty = _),DAE.ICONST(integer = ie1),DAE.ICONST(integer = ie2))
equation
val = safeIntOp(ie1,ie2,ExpressionSimplifyTypes.SUBOP());
then
val;
then val;

case (DAE.SUB(ty = _),DAE.RCONST(real = re1),DAE.RCONST(real = re2))
equation
re3 = re1 -. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.SUB(ty = _),DAE.RCONST(real = re1),DAE.ICONST(integer = ie2))
equation
e2_1 = intReal(ie2);
re3 = re1 -. e2_1;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.SUB(ty = _),DAE.ICONST(integer = ie1),DAE.RCONST(real = re2))
equation
e1_1 = intReal(ie1);
re3 = e1_1 -. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.MUL(ty = _),DAE.ICONST(integer = ie1),DAE.ICONST(integer = ie2))
equation
val = safeIntOp(ie1,ie2,ExpressionSimplifyTypes.MULOP());
then
val;
then val;

case (DAE.MUL(ty = _),DAE.RCONST(real = re1),DAE.RCONST(real = re2))
equation
re3 = re1 *. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.MUL(ty = _),DAE.RCONST(real = re1),DAE.ICONST(integer = ie2))
equation
e2_1 = intReal(ie2);
re3 = re1 *. e2_1;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.MUL(ty = _),DAE.ICONST(integer = ie1),DAE.RCONST(real = re2))
equation
e1_1 = intReal(ie1);
re3 = e1_1 *. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.DIV(ty = _),DAE.ICONST(integer = ie1),DAE.ICONST(integer = ie2))
equation
val = safeIntOp(ie1,ie2,ExpressionSimplifyTypes.DIVOP());
then
val;
then val;

case (DAE.DIV(ty = _),DAE.RCONST(real = re1),DAE.RCONST(real = re2))
equation
re3 = re1 /. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.DIV(ty = _),DAE.RCONST(real = re1),DAE.ICONST(integer = ie2))
equation
e2_1 = intReal(ie2);
re3 = re1 /. e2_1;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.DIV(ty = _),DAE.ICONST(integer = ie1),DAE.RCONST(real = re2))
equation
e1_1 = intReal(ie1);
re3 = e1_1 /. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

case (DAE.POW(ty = _),DAE.RCONST(real = re1),DAE.RCONST(real = re2))
equation
re3 = re1 ^. re2;
then
DAE.RCONST(re3);
then DAE.RCONST(re3);

end match;
end simplifyBinaryConst;
Expand Down Expand Up @@ -3770,13 +3724,12 @@ algorithm
// constants
case (_,oper,e1,e2)
equation
true = Expression.isConst(e1);
true = Expression.isConst(e2);
true = Expression.isConstValue(e1);
true = Expression.isConstValue(e2);
// print("simplifyBinaryConst " +& ExpressionDump.printExpStr(e1) +& ExpressionDump.binopSymbol1(oper) +& ExpressionDump.printExpStr(e2) +& "\n");
e3 = simplifyBinaryConst(oper, e1, e2);
// print("simplifyBinaryConst " +& ExpressionDump.printExpStr(e1) +& "," +& ExpressionDump.printExpStr(e2) +& " => " +& ExpressionDump.printExpStr(e3) +& "\n");
then
e3;
then e3;

// Look for empty arrays
case (_,oper,e1,e2)
Expand Down

0 comments on commit 00ebb6b

Please sign in to comment.