<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 - [X86][BMI] Pointer arithmetic prevents BEXTR lowering"
href="https://bugs.llvm.org/show_bug.cgi?id=38938">38938</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[X86][BMI] Pointer arithmetic prevents BEXTR lowering
</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: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>void update(int *counts, uint64_t *key) {
counts[(*key++ >> 21) & ((1 << 10) - 1)]++;
}
define void @update(i32* %a0, i64* %a1) {
%1 = load i64, i64* %a1, align 8
%2 = lshr i64 %1, 21
%3 = and i64 %2, 1023
%4 = getelementptr inbounds i32, i32* %a0, i64 %3
%5 = load i32, i32* %4, align 4
%6 = add nsw i32 %5, 1
store i32 %6, i32* %4, align 4
ret void
}
llc -mcpu=btver2
update:
movq (%rsi), %rax
shrq $19, %rax
andl $4092, %eax # imm = 0xFFC
incl (%rdi,%rax)
retq
Converting the index into a pointer stops bextr from being used, otherwise we'd
be able to lower to something like:
update:
movl $2581, %eax # imm = 0xA15
bextrl %eax, (%rsi), %eax
incl (%rdi,%rax,4)
retq</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>