<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] avgr patterns not recognized"
href="https://bugs.llvm.org/show_bug.cgi?id=50794">50794</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SIMD] avgr patterns not recognized
</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>Instead of i8x16.avgr_u and i16x8.avgr_u, these examples result in two
additions and a shift (Compiler Explorer: <a href="https://godbolt.org/z/7bKq4hTqj">https://godbolt.org/z/7bKq4hTqj</a>):
#include <wasm_simd128.h>
#pragma clang diagnostic ignored "-Wmissing-prototypes"
typedef uint8_t u8x16 __attribute__((__vector_size__(16)));
typedef uint16_t u16x8 __attribute__((__vector_size__(16)));
#if 0 // Copied from proposal
Lane-wise integer rounding average
i8x16.avgr_u(a: v128, b: v128) -> v128
i16x8.avgr_u(a: v128, b: v128) -> v128
Lane-wise rounding average:
def S.RoundingAverage(x, y):
return (x + y + 1) // 2
def S.avgr_u(a, b):
return S.lanewise_binary(S.RoundingAverage, S.AsUnsigned(a),
S.AsUnsigned(b))
#endif
u8x16 avgr8(u8x16 a, u8x16 b) {
return (a + b + 1) >> 1;
}
u16x8 avgr16(u16x8 a, u16x8 b) {
return (a + b + 1) >> 1;
}
u8x16 avgr8_div(u8x16 a, u8x16 b) {
return (a + b + 1) / 2;
}
u16x8 avgr16_div(u16x8 a, u16x8 b) {
return (a + b + 1) / 2;
}
u8x16 avgr8_intrin(u8x16 a, u8x16 b) {
return __builtin_wasm_avgr_u_i8x16(a, b);
}
u16x8 avgr16_intrin(u16x8 a, u16x8 b) {
return __builtin_wasm_avgr_u_i16x8(a, b);
}</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>