Opened 14 years ago

Closed 11 years ago

#1415 closed defect (fixed)

array bindings need to be handled better in the compiler

Reported by: sjoelund.se Owned by: sjoelund.se
Priority: high Milestone: 1.9.0
Component: Backend Version:
Keywords: Cc: sjoelund.se, AlexeyLebedev, Frenkel, TUD, wbraun

Description (last modified by sjoelund.se)

  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.

Change History (3)

comment:1 Changed 14 years ago by sjoelund.se

The binding x = fn(time) could be moved into the equation-section, which avoids some of these issues.

comment:2 Changed 11 years ago by sjoelund.se

  • Cc Frenkel TUD added; Frenkel TUD removed
  • Component set to Backend
  • Description modified (diff)

comment:3 Changed 11 years ago by sjoelund.se

  • Milestone set to 1.9.0
  • Resolution set to fixed
  • Status changed from new to closed

We now move the binding into the equation section.

Note: See TracTickets for help on using tickets.