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

    <tr>
        <th>Summary</th>
        <td>
            [SLP] Unable to finish compile in 1 hour caused by SLP Vectorizer with #66740
        </td>
    </tr>

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

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

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

<pre>
    I came across a very long compile time, which was unfinished after 1 hour on Intel i9 13900K with (some Verilator-generated C++ code)[https://github.com/cyyself/verilator-slow-compile-cases/tree/master/XiangShan-136f64975e-0a9b31bb30] since the commit a7f962c00745c8e28991379985fcd6b51ac0d671 and still exists in the current main branch (at least 8ca7e24b359ab2b6d2868f9252c7cd11eb48c787 have been confirmed).

Steps to reproduce the bug:

```bash
git clone https://github.com/cyyself/verilator-slow-compile-cases.git
cd XiangShan-136f64975e-0a9b31bb30
make CXX=clang++
```

After 1 hour, the clang process didn't stop. I attached gdb to clang, and [the stack dump](https://gist.github.com/cyyself/4d1473b46e0448d630aee3986ad24b71) shows it is running SLP Vectorizer.

I tried reverting commit a7f962c00745c8e28991379985fcd6b51ac0d671 based on commit 8ca7e24b359ab2b6d2868f9252c7cd11eb48c787. It finished in a few minutes.

I also tried to add `-fno-slp-vectorize` or remove `-fprofile-generate` based on commit 8ca7e24b359ab2b6d2868f9252c7cd11eb48c787. It also finished in a few minutes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE2L4zgQ_TXKpUiQJduyDjn0B4Fm5zDQ7NDXklS2tWNLQZKT7f31i5N0b2_D7AcDxga7qvze06uHOfshEO1Zc8-axw0uZYxpb19fM039xkT3un8CizMB2hRzBoQTpVeYYhjAxvnoJ4LiZ2LiAc6jtyOcMcMSeh98HskB9oUSVDDGJUEM8BQKTeA1VFJz_gucfRmBiS7HmeAbJT9h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