Skip to content

Commit

Permalink
Fix iterator order for -d=vectorizeBindings (#10799)
Browse files Browse the repository at this point in the history
Fixes #10794
  • Loading branch information
perost committed Jun 7, 2023
1 parent 56167bf commit 5e25023
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo
Expand Up @@ -1021,7 +1021,7 @@ algorithm
exp :: list(Dimension.sizeExp(d) for d in dims),
Binding.variability(binding), Purity.PURE, binding_ty);
else
iters := list((Subscript.toIterator(s), Dimension.toRange(d)) threaded for s in subs, d in dims);
iters := listReverse((Subscript.toIterator(s), Dimension.toRange(d)) threaded for s in subs, d in dims);

array_call := Call.TYPED_ARRAY_CONSTRUCTOR(binding_ty,
Expression.variability(exp), Expression.purity(exp), exp, iters);
Expand Down
1 change: 1 addition & 0 deletions testsuite/flattening/modelica/scodeinst/Makefile
Expand Up @@ -1111,6 +1111,7 @@ usertype3.mo \
usertype4.mo \
usertype5.mo \
usertype6.mo \
VectorizeBindings1.mo \
VectorTest.mo \
Visibility1.mo \
Visibility2.mo \
Expand Down
23 changes: 23 additions & 0 deletions testsuite/flattening/modelica/scodeinst/VectorizeBindings1.mo
@@ -0,0 +1,23 @@
// name: VectorizeBindings1
// keywords:
// status: correct
// cflags: -d=newInst,-nfScalarize,vectorizeBindings
//

model M
parameter Real p = 1;
parameter Real q = 2;
end M;

model VectorizeBindings1
parameter Real p = 2;
M m[2,3](each p = 2*p);
end VectorizeBindings1;

// Result:
// class VectorizeBindings1
// parameter Real p = 2.0;
// parameter Real[2, 3] m.q = fill(2.0, 2, 3);
// parameter Real[2, 3] m.p = array(array(2.0 * p for $m2 in 1:3) for $m1 in 1:2);
// end VectorizeBindings1;
// endResult

0 comments on commit 5e25023

Please sign in to comment.