Changeset 11943
 Timestamp:
 Nov 9, 2018 10:23:20 AM (13 months ago)
 Location:
 trunk/Compiler/ModelicaMiddleEnd
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Compiler/ModelicaMiddleEnd/src/jastadd/optimizations/CommonSubexpressionElimination.jrag
r11676 r11943 167 167 } 168 168 169 public void FIfExp.collectFunctionCalls(FClass.commonSubexpressionEliminationIfSet m) { 170 getIfExp().collectFunctionCalls(m); 171 /* In the branches we would have to consider the conditions (if expression) before we extract 172 * to a new equation. We also also have to consider the variability (is this a whenclause?). */ 173 } 174 169 175 public void FFunctionCall.collectFunctionCalls(FClass.commonSubexpressionEliminationIfSet m) { 170 176 /* We dont try to eliminate nested function call expressions to avoid some complicated cases */ 
trunk/Compiler/ModelicaMiddleEnd/test/modelica/CommonSubexpressionEliminationTests.mo
r10324 r11943 751 751 end Math; 752 752 753 model IfExp1 754 function f 755 input Real x; 756 output Real y; 757 algorithm 758 annotation(Inline=false); 759 end f; 760 761 Real x = time; 762 Real y = if f(time) > x then f(time) else f(time) + 1; 763 Real z = f(time); 764 765 annotation(__JModelica(UnitTesting(tests={ 766 TransformCanonicalTestCase( 767 name="IfExp1", 768 description="", 769 common_subexp_elim=true, 770 flatModel=" 771 fclass CommonSubexpressionEliminationTests.IfExp1 772 Real x; 773 Real y; 774 Real z; 775 equation 776 x = time; 777 y = if z > x then CommonSubexpressionEliminationTests.IfExp1.f(time) else CommonSubexpressionEliminationTests.IfExp1.f(time) + 1; 778 z = CommonSubexpressionEliminationTests.IfExp1.f(time); 779 780 public 781 function CommonSubexpressionEliminationTests.IfExp1.f 782 input Real x; 783 output Real y; 784 algorithm 785 return; 786 annotation(Inline = false); 787 end CommonSubexpressionEliminationTests.IfExp1.f; 788 789 end CommonSubexpressionEliminationTests.IfExp1; 790 ")}))); 791 end IfExp1; 792 793 model WhenExp1 794 function f 795 input Real x; 796 output Real y; 797 algorithm 798 annotation(Inline=false); 799 end f; 800 801 Real x = time; 802 Real y; 803 Real z = f(time); 804 equation 805 when f(time) > x then 806 y = f(time); 807 end when; 808 809 annotation(__JModelica(UnitTesting(tests={ 810 TransformCanonicalTestCase( 811 name="WhenExp1", 812 description="", 813 common_subexp_elim=true, 814 flatModel=" 815 fclass CommonSubexpressionEliminationTests.WhenExp1 816 Real x; 817 discrete Real y; 818 Real z; 819 discrete Boolean temp_1; 820 initial equation 821 pre(y) = 0.0; 822 pre(temp_1) = false; 823 equation 824 temp_1 = z > x; 825 y = if temp_1 and not pre(temp_1) then CommonSubexpressionEliminationTests.WhenExp1.f(time) else pre(y); 826 x = time; 827 z = CommonSubexpressionEliminationTests.WhenExp1.f(time); 828 829 public 830 function CommonSubexpressionEliminationTests.WhenExp1.f 831 input Real x; 832 output Real y; 833 algorithm 834 return; 835 annotation(Inline = false); 836 end CommonSubexpressionEliminationTests.WhenExp1.f; 837 838 end CommonSubexpressionEliminationTests.WhenExp1; 839 ")}))); 840 end WhenExp1; 841 753 842 end CommonSubexpressionEliminationTests;
Note: See TracChangeset
for help on using the changeset viewer.