<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] Repeated immediate constants in ctpop expansion"
href="https://bugs.llvm.org/show_bug.cgi?id=41151">41151</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[X86] Repeated immediate constants in ctpop expansion
</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>andrea.dibiagio@gmail.com, craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>The constants used for ctpop expansion are duplicated when we split (e.g. i64
on i686, i128 on x86_64) - ideally we'd reuse these (or at least copy the reg
if we have the spare registers to avoid bulky i32 immediates).
<a href="https://godbolt.org/z/R8zyHg">https://godbolt.org/z/R8zyHg</a>
define i64 @ctpop64(i64 %a0) {
%r = call i64 @llvm.ctpop.i64(i64 %a0)
ret i64 %r
}
declare i64 @llvm.ctpop.i64(i64)
llc -mtriple=i686--
ctpop64: # @ctpop64
movl 4(%esp), %eax
movl 8(%esp), %ecx
movl %ecx, %edx
shrl %edx
andl $1431655765, %edx # imm = 0x55555555
subl %edx, %ecx
movl %ecx, %edx
andl $858993459, %edx # imm = 0x33333333
shrl $2, %ecx
andl $858993459, %ecx # imm = 0x33333333
addl %edx, %ecx
movl %ecx, %edx
shrl $4, %edx
addl %ecx, %edx
andl $252645135, %edx # imm = 0xF0F0F0F
imull $16843009, %edx, %ecx # imm = 0x1010101
shrl $24, %ecx
movl %eax, %edx
shrl %edx
andl $1431655765, %edx # imm = 0x55555555
subl %edx, %eax
movl %eax, %edx
andl $858993459, %edx # imm = 0x33333333
shrl $2, %eax
andl $858993459, %eax # imm = 0x33333333
addl %edx, %eax
movl %eax, %edx
shrl $4, %edx
addl %eax, %edx
andl $252645135, %edx # imm = 0xF0F0F0F
imull $16843009, %edx, %eax # imm = 0x1010101
shrl $24, %eax
addl %ecx, %eax
xorl %edx, %edx
retl</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>