<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 - Missed opportunity vectorization with __uint128_t"
href="https://bugs.llvm.org/show_bug.cgi?id=40716">40716</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed opportunity vectorization with __uint128_t
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gchatelet@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Bitwise operations on __uint128_t do not take advantage of vector operations:
__uint128_t xor_512_128(const __uint128_t* a, const __uint128_t* b) {
return (a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]);
}
xor_512_128(unsigned __int128 const*, unsigned __int128 const*):
mov rax, qword ptr [rsi]
mov rdx, qword ptr [rsi + 8]
xor rdx, qword ptr [rdi + 8]
xor rax, qword ptr [rdi]
mov r8, qword ptr [rsi + 16]
mov rcx, qword ptr [rsi + 24]
xor rcx, qword ptr [rdi + 24]
or rcx, rdx
xor r8, qword ptr [rdi + 16]
or r8, rax
mov r9, qword ptr [rsi + 40]
mov r10, qword ptr [rsi + 32]
xor r10, qword ptr [rdi + 32]
xor r9, qword ptr [rdi + 40]
mov rax, qword ptr [rsi + 48]
mov rdx, qword ptr [rsi + 56]
xor rdx, qword ptr [rdi + 56]
or rdx, r9
or rdx, rcx
xor rax, qword ptr [rdi + 48]
or rax, r10
or rax, r8
ret
Whereas uint64_t do vectorize
__uint128_t xor_512_64(const uint64_t* a, const uint64_t* b) {
return (a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]);
}
xor_512_64(unsigned long const*, unsigned long const*):
vmovdqu ymm0, ymmword ptr [rsi]
vmovdqu ymm1, ymmword ptr [rsi + 32]
vpxor ymm1, ymm1, ymmword ptr [rdi + 32]
vpxor ymm0, ymm0, ymmword ptr [rdi]
vpor ymm0, ymm0, ymm1
vextracti128 xmm1, ymm0, 1
vpor xmm0, xmm0, xmm1
vpshufd xmm1, xmm0, 78 # xmm1 = xmm0[2,3,0,1]
vpor xmm0, xmm0, xmm1
vmovq rax, xmm0
xor edx, edx
vzeroupper
ret
<a href="https://godbolt.org/z/mwOeNm">https://godbolt.org/z/mwOeNm</a></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>