<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65142>65142</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Long compile times and large memory usage for complex number expressions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DavidTruby
      </td>
    </tr>
</table>

<pre>
    Complex number expressions seem to take a long time to compile and use a lot of memory in some cases. This seems to be due to time taken in the folding code for complex numbers. As an example, the attached code takes 12 minutes to compile for me and ends up swapping to disk:

```fortran
PROGRAM ProgramName0
 COMPLEX complexVar0
 REAL realVar0
 INTEGER intVar0
 
 complexVar0 = (8,1.542956)**9/intVar0/realVar0+6+intVar0+intVar0**5-4&
 &+intVar0**intVar0/8**intVar0/intVar&
 &0/intVar0+0/3-3+9/9/5+7+5**0*0**10-0/2**1**2-4+intVar0*intVar0-3**intVar0-6

END PROGRAM
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU1uPszgM_TXhxWoVzKXlgYdeRyvNTdVota8BXJodkqAkzOXfrwLtlB19EiGJzTk-yD7COdlqopJlW5btIzH4i7HlXnzI5s0O1XdUmea73BnVd_QFelAVWaCv3pJz0mgHjkiBN-DFO4GAzugWvFQUYrVRvewIhG5gcFPagzmDImXsN0gNziiCWjhyS3i7yInPBXBF0AwjzUQn3kkHhL8QnE3XSN1CbZpwsWOlu0C3hI0DoYG-RIgz3I0w4b2oL9RMuMDoIEZQUg-e3Fxx4FSTcNKNg6EH9yn6PhT1Bhrp3lmyYXzP-O2d8-k5G-ut0FP09fTycNo8was1rRXqWSjiUwZ2L0-vj4d_btL_FvaWOR02j2BJdLPYX89vh4fDCaT2s-h1m1EAS_bAcL1muIuXWYpFljMsGG4YbgqGxxsBHn8q4DZnuP1J3E8Bky1ShvmtHua_83e-9e_AdPofms8VbMMtWSQMt0FZWBnD7YrhNpu4-HUx3MR8ET7H623aMIib6bmeAuVMyiKfN-rwvIdrW351LmrKpCmSQkRUxnmRpAUv8jS6lFmW8CQ9J6s8E7wRRVOtqgLXVMVVwWvikSyRY8LXSRynvEBcFiuskrRoViIVtVgTSzkpIbtl132opbFtJJ0bqMyzOMWoExV1bvQgoqZPGJMMMVjSlgGzqIbWsZR30nl3Z_HSd6N5z53QLcv28GhGX0xjHJzjxinuhG3p5rvBifZPvpkbOxpsV168710YdDwyPLbSX4ZqWRvF8BgkXLdFb82_VPvQ2yDcMTyOP_ZfAAAA__-M2lc8">