<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62283>62283</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
std::exp not vectorized on static sized array
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vient
</td>
</tr>
</table>
<pre>
Hi, Clang documentation on Loop Vectorizer mentions [vectorizing of mathematical functions](https://llvm.org/docs/Vectorizers.html#vectorization-of-function-calls). I created a small test case, using latest Clang and GCC with `-std=c++20 -march=skylake -Ofast`: https://godbolt.org/z/dq1EGqszs
```cpp
#include <array>
#include <cmath>
#include <numeric>
extern void use(auto&);
extern void use(auto&&);
int main() {
double d[4], e[4];
for (auto& x : d) {
use(x);
}
for (size_t i = 0; i < std::size(d); ++i) {
e[i] = std::exp(d[i]); // should be vectorized
}
use(std::accumulate(std::begin(e), std::end(e), 0.));
}
```
GCC successfully inserted call to `_ZGVdN4v_exp` while Clang just calls `exp` 4 times. Array size or using float do not affect this. In this case Clang should be able to vectorize `exp` calls, right?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVFuv2jgQ_jXDywgU7ATIQx64lLOVVrtvfdiXI8eeELeOTWObc_n1K5twoNtWi5BjzYy_uX_Ce32yRA1UO6gOMxFD78bmosmGWevUW_OHBrbHvRH2hMrJOJANImhn0Vn807kzfiEZ3KjfacSk1M56hGp3mcTantB1OIjQ0yCClsJgF63MhlAdgG36EM4e-BbYEdjRmMuwcOMJ2FE56YEd7x78og-DAcZv6DmUuevmN8i5FMZ4YPUCP6McSQRSKNAPwhgM5ANK4SnlFH0KzYgsvCYorMKn_R5fdOgRVsXcBwX8IIHtgO1YgfNBjLIHfvDf3oz4Rjj_uxM-wKoAvsUf8zg51ToTplTeUzrfl5-evvt3D8UBim16lf_yfJ4kjGsrTVSEwPdiHMUb8E-_0slUz9_obBxo1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