[llvm-bugs] [Bug 50247] New: [SIMD] calling math builtins (sqrt, ceil, floor, trunc, round) in loop not vectorized
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu May 6 11:14:29 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50247
Bug ID: 50247
Summary: [SIMD] calling math builtins (sqrt, ceil, floor,
trunc, round) in loop not vectorized
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: WebAssembly
Assignee: unassignedbugs at nondot.org
Reporter: clang at evan.coeusgroup.com
CC: llvm-bugs at lists.llvm.org
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 https://godbolt.org/z/v95YvPTGe):
#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
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210506/892295f7/attachment.html>
More information about the llvm-bugs
mailing list