Changeset 14169


Ignore:
Timestamp:
Nov 25, 2019 2:18:12 PM (3 weeks ago)
Author:
Jonathan Kämpe
Message:

#5883 Adding test case with unnecessary temporaries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-jk-2720/Compiler/ModelicaMiddleEnd/test/modelica/AlgorithmTests.mo

    r14165 r14169  
    714714end TempAssign4;
    715715
     716model TempAssign5
     717    record R1
     718        Real[2] x = {1,2};
     719    end R1;
     720   
     721    record R2
     722        R1 r1a;
     723        R1 r1b;
     724    end R2;
     725   
     726    record R3
     727        R2 r2a;
     728        R2 r2b;
     729    end R3;
     730   
     731   
     732    function f
     733        input Real x;
     734        R2 r2;
     735        R3 r3;
     736        output R1 r;
     737    algorithm
     738        r2.r1a.x := {x,1};
     739        r2.r1b.x := r2.r1a.x;
     740       
     741        r3.r2a.r1a.x := r2.r1a.x;
     742        r3.r2a.r1b.x := r3.r2a.r1a.x;
     743       
     744        r3.r2b.r1a.x := r3.r2a.r1b.x;
     745        r3.r2b.r1b.x := r3.r2b.r1a.x;
     746       
     747        r := r3.r2b.r1b;
     748       
     749        annotation(Inline=false);
     750    end f;
     751   
     752    R1 r = f(time);
     753annotation(__JModelica(UnitTesting(tests={
     754    TransformCanonicalTestCase(
     755        name="TempAssign5",
     756        description="Scalarizing assignment temp generation",
     757        flatModel="
     758fclass AlgorithmTests.TempAssign5
     759 Real r.x[1];
     760 Real r.x[2];
     761equation
     762 (AlgorithmTests.TempAssign5.R1({r.x[1], r.x[2]})) = AlgorithmTests.TempAssign5.f(time);
     763
     764public
     765 function AlgorithmTests.TempAssign5.f
     766  input Real x;
     767  AlgorithmTests.TempAssign5.R2 r2;
     768  AlgorithmTests.TempAssign5.R3 r3;
     769  output AlgorithmTests.TempAssign5.R1 r;
     770  Integer[:] temp_1;
     771  Integer[:] temp_2;
     772  Integer[:] temp_3;
     773  Integer[:] temp_4;
     774  Integer[:] temp_5;
     775  Integer[:] temp_6;
     776  Integer[:] temp_7;
     777  Real[:] temp_8;
     778  Real[:] temp_9;
     779  Real[:] temp_10;
     780  Real[:] temp_11;
     781  Real[:] temp_12;
     782  Real[:] temp_13;
     783 algorithm
     784  init temp_1 as Integer[2];
     785  temp_1[1] := 1;
     786  temp_1[2] := 2;
     787  for i1 in 1:2 loop
     788   r2.r1a.x[i1] := temp_1[i1];
     789  end for;
     790  init temp_2 as Integer[2];
     791  temp_2[1] := 1;
     792  temp_2[2] := 2;
     793  for i1 in 1:2 loop
     794   r2.r1b.x[i1] := temp_2[i1];
     795  end for;
     796  init temp_3 as Integer[2];
     797  temp_3[1] := 1;
     798  temp_3[2] := 2;
     799  for i1 in 1:2 loop
     800   r3.r2a.r1a.x[i1] := temp_3[i1];
     801  end for;
     802  init temp_4 as Integer[2];
     803  temp_4[1] := 1;
     804  temp_4[2] := 2;
     805  for i1 in 1:2 loop
     806   r3.r2a.r1b.x[i1] := temp_4[i1];
     807  end for;
     808  init temp_5 as Integer[2];
     809  temp_5[1] := 1;
     810  temp_5[2] := 2;
     811  for i1 in 1:2 loop
     812   r3.r2b.r1a.x[i1] := temp_5[i1];
     813  end for;
     814  init temp_6 as Integer[2];
     815  temp_6[1] := 1;
     816  temp_6[2] := 2;
     817  for i1 in 1:2 loop
     818   r3.r2b.r1b.x[i1] := temp_6[i1];
     819  end for;
     820  init temp_7 as Integer[2];
     821  temp_7[1] := 1;
     822  temp_7[2] := 2;
     823  for i1 in 1:2 loop
     824   r.x[i1] := temp_7[i1];
     825  end for;
     826  init temp_8 as Real[2];
     827  temp_8[1] := x;
     828  temp_8[2] := 1;
     829  for i1 in 1:2 loop
     830   r2.r1a.x[i1] := temp_8[i1];
     831  end for;
     832  init temp_9 as Real[2];
     833  for i1 in 1:2 loop
     834   temp_9[i1] := r2.r1a.x[i1];
     835  end for;
     836  for i1 in 1:2 loop
     837   r2.r1b.x[i1] := temp_9[i1];
     838  end for;
     839  init temp_10 as Real[2];
     840  for i1 in 1:2 loop
     841   temp_10[i1] := r2.r1a.x[i1];
     842  end for;
     843  for i1 in 1:2 loop
     844   r3.r2a.r1a.x[i1] := temp_10[i1];
     845  end for;
     846  init temp_11 as Real[2];
     847  for i1 in 1:2 loop
     848   temp_11[i1] := r3.r2a.r1a.x[i1];
     849  end for;
     850  for i1 in 1:2 loop
     851   r3.r2a.r1b.x[i1] := temp_11[i1];
     852  end for;
     853  init temp_12 as Real[2];
     854  for i1 in 1:2 loop
     855   temp_12[i1] := r3.r2a.r1b.x[i1];
     856  end for;
     857  for i1 in 1:2 loop
     858   r3.r2b.r1a.x[i1] := temp_12[i1];
     859  end for;
     860  init temp_13 as Real[2];
     861  for i1 in 1:2 loop
     862   temp_13[i1] := r3.r2b.r1a.x[i1];
     863  end for;
     864  for i1 in 1:2 loop
     865   r3.r2b.r1b.x[i1] := temp_13[i1];
     866  end for;
     867  for i1 in 1:2 loop
     868   r.x[i1] := r3.r2b.r1b.x[i1];
     869  end for;
     870  return;
     871 annotation(Inline = false);
     872 end AlgorithmTests.TempAssign5.f;
     873
     874 record AlgorithmTests.TempAssign5.R1
     875  Real x[2];
     876 end AlgorithmTests.TempAssign5.R1;
     877
     878 record AlgorithmTests.TempAssign5.R2
     879  AlgorithmTests.TempAssign5.R1 r1a;
     880  AlgorithmTests.TempAssign5.R1 r1b;
     881 end AlgorithmTests.TempAssign5.R2;
     882
     883 record AlgorithmTests.TempAssign5.R3
     884  AlgorithmTests.TempAssign5.R2 r2a;
     885  AlgorithmTests.TempAssign5.R2 r2b;
     886 end AlgorithmTests.TempAssign5.R3;
     887
     888end AlgorithmTests.TempAssign5;
     889")})));
     890end TempAssign5;
     891
    716892model UnusedBranch1
    717893    Real x;
Note: See TracChangeset for help on using the changeset viewer.