Skip to content

Commit

Permalink
- Run simplify on any algorithm statement generated
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8530 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 7, 2011
1 parent 14f63d3 commit bc9497a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Ceval.mo
Expand Up @@ -975,7 +975,7 @@ algorithm
(cache, e2, _) = cevalIfConstant(cache, inEnv, e2, inProp, impl);
then
(inCache, DAE.RANGE(ty, e1, e3, e2));
case (_, _, _, _, _) then (inCache, inExp);
else (inCache, inExp);
end matchcontinue;
end cevalRangeIfConstant;

Expand Down
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/DAEUtil.mo
Expand Up @@ -3919,9 +3919,11 @@ algorithm
equation
((e_1, extraArg)) = func((e, extraArg));
failure(((DAE.CREF(_,_), _)) = func((Expression.crefExp(cr), extraArg)));
/* We need to pass this through because simplify/etc may scalarize the cref...
true = RTOpts.debugFlag("failtrace");
print(DAEDump.ppStatementStr(x));
print("Warning, not allowed to set the componentRef to a expression in DAEUtil.traverseDAEEquationsStmts\n");
*/
(xs_1, extraArg) = traverseDAEEquationsStmts(xs, func, extraArg);
then (DAE.STMT_ASSIGN_ARR(tp,cr,e_1,source) :: xs_1,extraArg);

Expand Down
3 changes: 2 additions & 1 deletion Compiler/FrontEnd/InstSection.mo
Expand Up @@ -2201,6 +2201,7 @@ algorithm
source = DAEUtil.createElementSource(Absyn.dummyInfo, Env.getEnvPath(env), PrefixUtil.prefixToCrefOpt(pre), NONE(), NONE());

(cache,statements_1) = instStatements(cache, env, ih, pre, statements, source, SCode.NON_INITIAL(), impl, unrollForLoops);
(statements_1,_) = DAEUtil.traverseDAEEquationsStmts(statements_1,Expression.traverseSubexpressionsHelper,(ExpressionSimplify.simplifyWork,false));

dae = DAE.DAE({DAE.ALGORITHM(DAE.ALGORITHM_STMTS(statements_1),source)});
then
Expand Down Expand Up @@ -2260,6 +2261,7 @@ algorithm
source = DAEUtil.createElementSource(Absyn.dummyInfo, Env.getEnvPath(env), PrefixUtil.prefixToCrefOpt(pre), NONE(), NONE());

(cache,statements_1) = instStatements(cache, env, ih, pre, statements, source, SCode.INITIAL(), impl, unrollForLoops);
(statements_1,_) = DAEUtil.traverseDAEEquationsStmts(statements_1,Expression.traverseSubexpressionsHelper,(ExpressionSimplify.simplifyWork,false));

dae = DAE.DAE({DAE.INITIALALGORITHM(DAE.ALGORITHM_STMTS(statements_1),source)});
then
Expand Down Expand Up @@ -4425,7 +4427,6 @@ algorithm
case (cache,env,ih,pre,SCode.ALG_ASSIGN(assignComponent=var,value=value,info=info),source,initial_,impl,unrollForLoops,_)
equation
(cache,e_1,eprop,_) = Static.elabExp(cache,env,value,impl,NONE(),true,pre,info);
e_1 = ExpressionSimplify.simplify(e_1);
(cache,stmts) = instAssignment2(cache,env,ih,pre,var,e_1,eprop,info,source,initial_,impl,unrollForLoops);
then (cache,stmts);

Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -1777,7 +1777,6 @@ algorithm
co = Types.constAnd(start_c, stop_c);
(cache, ty) = elabRangeType(cache, inEnv, start_exp, NONE(), stop_exp, start_t, ety, inImpl);
range_exp = DAE.RANGE(ety, start_exp, NONE(), stop_exp);
range_exp = ExpressionSimplify.simplify(range_exp);
then
(cache, range_exp, DAE.PROP(ty, co), st);

Expand All @@ -1795,7 +1794,6 @@ algorithm
co = Types.constAnd(start_c, stop_c);
(cache, ty) = elabRangeType(cache, inEnv, start_exp, SOME(step_exp), stop_exp, start_t, ety, inImpl);
range_exp = DAE.RANGE(ety, start_exp, SOME(step_exp), stop_exp);
range_exp = ExpressionSimplify.simplify(range_exp);
then
(cache, range_exp, DAE.PROP(ty, co), st);

Expand Down

0 comments on commit bc9497a

Please sign in to comment.