#3910 closed defect (fixed)
Very strange behaviour of CSE
| Reported by: | Francesco Casella | Owned by: | Patrick Täuber |
|---|---|---|---|
| Priority: | critical | Milestone: | |
| Component: | Backend | Version: | |
| Keywords: | Cc: | jan.hagemann@… |
Description
Consider the following package:
model Test1
Real x;
Real y;
Real z;
Real w(fixed = true);
equation
der(w) = 1 - w;
x = 3*sin(w);
y = 3*sin(w);
z = 6*sin(w)-1;
end Test1;
model Test2
Real x(fixed = true);
Real y;
Real z;
equation
der(x) = 1 - x;
y = sin(x);
z = 2*sin(x);
end Test2;
end CSE;
and execute the following script:
setDebugFlags("dumpCSE"); getErrorString();
setCommandLineOptions("--postOptModules+=wrapFunctionCalls"); getErrorString();
simulate(CSE.Test1); getErrorString();
simulate(CSE.Test2); getErrorString();
In the first test case, the CSE is performed correctly and the term sin(w) is only computed once. In the second one, instead, no CSE is performed at all.
I am unable to understand what is the structural difference between the two test cases.
Attachments (1)
Change History (5)
by , 10 years ago
| Attachment: | testStrangeCSE.mos added |
|---|
comment:1 by , 10 years ago
possible it is
CommonSubExpression.wrapFunctionCalls_advanced ... case (DAE.CALL(), DAE.CREF()) // sin(x) = y;
comment:2 by , 10 years ago
yes, that is right. y is also a cse variable, but nevertheless there is a bug. the boolean to restart the matching has to be true. i will fix it tomorrow. this is also the reasons for the problems in ticket 3102 (testIF97CSE.mos).
Note:
See TracTickets
for help on using tickets.

.mos file to reproduce the problem