Skip to content

Commit

Permalink
- Added flag +scalarizeMinMax to enable scalarization of min/max redu…
Browse files Browse the repository at this point in the history
…ctions.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15309 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Feb 25, 2013
1 parent 0cab705 commit 6a02fca
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,17 @@ algorithm
e = Expression.makeLBinary(expl,DAE.OR(DAE.T_BOOL_DEFAULT));
then e;

case DAE.CALL(path=Absyn.IDENT(name), expLst = {DAE.ARRAY(array = expl as _ :: _ :: _)},
attr = DAE.CALL_ATTR(ty = tp))
equation
true = Config.scalarizeMinMax();
true = stringEq(name, "max") or stringEq(name, "min");
e1 :: e2 :: expl = listReverse(expl);
e1 = Expression.makeBuiltinCall(name, {e2, e1}, tp);
e1 = List.fold2(expl, makeNestedReduction, name, tp, e1);
then
e1;

// cross
case (e as DAE.CALL(path = Absyn.IDENT("cross"), expLst = expl))
equation
Expand Down Expand Up @@ -1151,6 +1162,16 @@ algorithm
end matchcontinue;
end simplifyBuiltinCalls;

protected function makeNestedReduction
input DAE.Exp inExp;
input String inName;
input DAE.Type inType;
input DAE.Exp inCall;
output DAE.Exp outCall;
algorithm
outCall := Expression.makeBuiltinCall(inName, {inExp, inCall}, inType);
end makeNestedReduction;

protected function simplifySymmetric
input array<array<DAE.Exp>> marr;
input Integer i1;
Expand Down

0 comments on commit 6a02fca

Please sign in to comment.