Opened 14 years ago
Last modified 12 years ago
#1415 closed defect
array bindings need to be handled better in the compiler — at Initial Version
Reported by: | Martin Sjölund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | 1.9.0 |
Component: | Backend | Version: | |
Keywords: | Cc: | Martin Sjölund, AlexeyLebedev, Frenkel, TUD, Willi Braun |
Description
{{{ class ArrayCall
function fn
input Real r;
output Real array[10];
algorithm
array := 1:10.0;
array := cos(r*array);
end fn;
Real x[10] = fn(time);
end ArrayCall;}}}
Either we do common subexpression elimination in the backend or keep the arrays non-expanded. Common subexpression elimination would of course be preferrable as then we could do things like:
{{{class ArrayCall
Real x[10] = fn(time);
Real y[10] = fn(time)*2;
Real z[10] = fn(time)*3;
end ArrayCall;}}}
And only call fn once. We probably need to introduce temporary variables to deal with duplicated function calls.