<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [SIMD] calling math builtins (sqrt, ceil, floor, trunc, round) in loop not vectorized"
href="https://bugs.llvm.org/show_bug.cgi?id=50247">50247</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SIMD] calling math builtins (sqrt, ceil, floor, trunc, round) in loop not vectorized
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>clang@evan.coeusgroup.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>WASM SIMD128 includes several vector math functions which correspond to scalar
builtins in clang, but calling them for each element in a loop doesn't result
in the appropriate vector instruction.
Here is an example (also at <a href="https://godbolt.org/z/v95YvPTGe">https://godbolt.org/z/v95YvPTGe</a>):
#include <wasm_simd128.h>
__f32x4
f32x4_sqrt(__f32x4 a) {
#if USE_BUILTIN
return __builtin_wasm_sqrt_f32x4(a);
#else
__f32x4 r;
for (int i = 0 ; i < 4 ; i++) {
r[i] = __builtin_sqrtf(a[i]);
}
return r;
#endif
}
__f64x2
f64x2_sqrt(__f64x2 a) {
#if USE_BUILTIN
return __builtin_wasm_sqrt_f64x2(a);
#else
__f64x2 r;
for (int i = 0 ; i < 2 ; i++) {
r[i] = __builtin_sqrt(a[i]);
}
return r;
#endif
}
__f32x4
f32x4_ceil(__f32x4 a) {
#if USE_BUILTIN
return __builtin_wasm_ceil_f32x4(a);
#else
__f32x4 r;
for (int i = 0 ; i < 4 ; i++) {
r[i] = __builtin_ceilf(a[i]);
}
return r;
#endif
}
__f64x2
f64x2_ceil(__f64x2 a) {
#if USE_BUILTIN
return __builtin_wasm_ceil_f64x2(a);
#else
__f64x2 r;
for (int i = 0 ; i < 2 ; i++) {
r[i] = __builtin_ceil(a[i]);
}
return r;
#endif
}
__f32x4
f32x4_floor(__f32x4 a) {
#if USE_BUILTIN
return __builtin_wasm_floor_f32x4(a);
#else
__f32x4 r;
for (int i = 0 ; i < 4 ; i++) {
r[i] = __builtin_floorf(a[i]);
}
return r;
#endif
}
__f64x2
f64x2_floor(__f64x2 a) {
#if USE_BUILTIN
return __builtin_wasm_floor_f64x2(a);
#else
__f64x2 r;
for (int i = 0 ; i < 2 ; i++) {
r[i] = __builtin_floor(a[i]);
}
return r;
#endif
}
__f32x4
f32x4_trunc(__f32x4 a) {
#if USE_BUILTIN
return __builtin_wasm_trunc_f32x4(a);
#else
__f32x4 r;
for (int i = 0 ; i < 4 ; i++) {
r[i] = __builtin_truncf(a[i]);
}
return r;
#endif
}
__f64x2
f64x2_trunc(__f64x2 a) {
#if USE_BUILTIN
return __builtin_wasm_trunc_f64x2(a);
#else
__f64x2 r;
for (int i = 0 ; i < 2 ; i++) {
r[i] = __builtin_trunc(a[i]);
}
return r;
#endif
}
__f32x4
f32x4_nearest(__f32x4 a) {
#if USE_BUILTIN
return __builtin_wasm_nearest_f32x4(a);
#else
__f32x4 r;
for (int i = 0 ; i < 4 ; i++) {
r[i] = __builtin_roundf(a[i]);
}
return r;
#endif
}
__f64x2
f64x2_nearest(__f64x2 a) {
#if USE_BUILTIN
return __builtin_wasm_nearest_f64x2(a);
#else
__f64x2 r;
for (int i = 0 ; i < 2 ; i++) {
r[i] = __builtin_round(a[i]);
}
return r;
#endif
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>