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

    <tr>
        <th>Summary</th>
        <td>
            missed-optimization: std::reverse is not vectorized
        </td>
    </tr>

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

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

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

<pre>
    GCC auto-vectorizes std::reverse but LLVM cannot(for now)

*Note: This was discussed in a recent meetup about vectorizer, just adding this issue for record keeping sake.*


CE: https://gcc.godbolt.org/z/ofad57WqM 
Code:
```
#include <algorithm>
#include <vector>

void reverse_vector(std::vector<int> &v){
    std::reverse(v.begin(), v.end());
}
```
Output of `-Rpass-analysis=loop-vectorize`:
```
In file included from <source>:1:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/algorithm:61:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/bits/stl_algo.h:1060:7: remark: loop not vectorized: could not determine number of loop iterations [-Rpass-analysis=loop-vectorize]
 1060 |       while (__first < __last)
      |       ^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVEuP4zYT_DXtS0OCRD0sHXTweEYfPmA3AYIgORqU2La5Q5EKH57Hrw8oa8abmV3kGkOgbZJFVleXijsnT5qog-oOqvsND_5sbDdZwV8GacVmMOKl-99-jzx4k1xo9MbKV3LovIBiB8XO0oWsIxyCxy9f_viKI9faeGDN0VjU5glYC9k9ZLt1ZLtfjCcodvj7WTp84g6FdGNwjgRKjRwtjaQ9TkQ-zMgHEzy-X22B7fFbcB65EFKf0MdTpHOBMN5oaTRW4CPRHFcdf6QU2O4fFJZx_xA5nL2fXayE9cD60zimJyMGo3xq7AlY_wqsN0cuqu2ff33FFWlE5L8eVmfrs5ZXSD2qIAih2HN1Mlb68wTFw4_Wr1XdFpfxYqTAVdbDuoM174K_YfZSeygeEFh9iRpv765wRPzUHWDNJR3oJDWwJm5me7ykpMXb3xaKFQ7b-x8W9mvwc_Bojgh1lvw2c-cSrrl6cdJBca-MmW_-iKifCPR_jUepCFcVBB6tmaIWzgQ7UtSi2OXv6J9sZ72ZPbB-NNMsFdmEnmdlbHRHbGLiNJ_dOdqwV3K4TgLrn5v6UJeJkjo8JycdgPV5lWZpBqxP08_Demu8CNjd8twA3zV3V98Y_ye4DdI7YL3z6hBppucoarZ0ZRttb2ni9jH-io1Dbb57w6J1cDRBiWVekCc7SU2owzSQjRZYQNKT5V4a7RCqu3-1RLX6CiMPhO0er5-nc-wvsOZwOErrfPQCHg6KO_8eHdedNwxUDx_MtRFdIdqi5Rvq8m1etVVVNeXm3G1FcWzKuslYfczz7VCM7VjlVUViKMp2aDayYxkrsyrf5mXelixth7LIx6yu6pZT3QooM5q4VKlSlynGwmZJm65lVVVuFB9IuSVAGdP0dI0iYCzmqe0iJhnCyUGZKem8u53ipVfUTTIGX2JmLyf5uugZ9f-Ur9J96NImWNV9iC_pz2FIRzNFb6nL21cyW_ONxui4hV20xsL-7wAAAP__0jnRZA">