Opened 15 years ago
Last modified 14 years ago
#1503 closed defect (fixed)
Optimize backend control-flow after symbolic manipulations
| Reported by: | Martin Sjölund | Owned by: | Martin Sjölund | 
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Version: | ||
| Keywords: | Cc: | Martin Sjölund, Frenkel TUD, Willi Braun | 
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*/
  }
      
  Note:
 See   TracTickets
 for help on using tickets.
    

resolved in 10865