Opened 2 years ago

Closed 16 months ago

Last modified 16 months ago

#5511 closed defect (fixed)

Branch selection of if expressions

Reported by: Jonathan Kämpe Owned by: Jonathan Kämpe
Priority: major Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:

Description (last modified by Jonathan Kämpe)

FIfExp.isParameterIf and FIfExp.cevalSelectExp are used frequently in attributes in FIfExp. We need to replace isParameterIf (in most places) with getIfExp().variability().knownParameterOrLess() and make sure that the test-expression is marked as structural. This is to reduce the number of unnecessary evaluations, for example FIfExp.size(), when called in the flat tree, will always re-evaluate a parameter test expression. It is also necessary since changing the parameter should generate an error, rather than silently doing nothing.

The test CCodeGenArrayTests.RecordArray8 (among probably many more) depends on the old behavior. The resulting c-code selects a branch even though the parameter is not marked as structural. This is due to the array size being in a record, that needs to be fixed as well.

Change History (5)

comment:1 Changed 2 years ago by Jonathan Kämpe

Description: modified (diff)

comment:2 Changed 2 years ago by Jonathan Kämpe

Summary: Branch selection of if equationsBranch selection of if expressions

comment:3 Changed 2 years ago by Jesper Mattsson

Shouldn't we also eliminate the if-expression in the flat tree if the test is knownParameterOrLess()?

comment:4 Changed 16 months ago by Jesper Mattsson

Resolution: fixed
Status: assignedclosed


Removed evaluation of if expressions with parameter test in the flat tree, it is now only done in instance tree.

comment:5 Changed 16 months ago by amartensen

Review comments:

Note: See TracTickets for help on using tickets.