Opened 13 years ago

Last modified 13 years ago

#1503 closed defect (fixed)

Optimize backend control-flow after symbolic manipulations

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

Description

model M
  Boolean b1 = true;
  Boolean b2 = b1;
  Real x;
  Real y;
algorithm
  if b2 then
    x := 3.5;
  else
    x := 4.5;
  end if;
equation
  when b2 then
    y = 5.5;
  end when;
end M;

This will surely not be optimized by GCC... We know a constant expression can never trigger an edge event, so why generate this code :)

  localData->helpVars[0] = (1);
  if (edge(localData->helpVars[0])) {
    $Py = 5.5;
  } else {
    $Py = pre($Py);
  }

Sure, the if-statement might be optimized by gcc, but eliminating dead code speeds up subsequent traversals of the DAE (including code generation)...

  if ((1)) {
    /*#modelicaLine [a.mo:8:5-8:13]*/
    $Px = 3.5;
    /*#endModelicaLine*/
  }
  else {
    /*#modelicaLine [a.mo:10:5-10:13]*/
    $Px = 4.5;
    /*#endModelicaLine*/
  }

Change History (1)

comment:1 Changed 13 years ago by Frenkel TUD

resolved in 10865

Note: See TracTickets for help on using tickets.