[llvm-bugs] [Bug 41151] New: [X86] Repeated immediate constants in ctpop expansion
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 20 03:50:37 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41151
Bug ID: 41151
Summary: [X86] Repeated immediate constants in ctpop expansion
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: andrea.dibiagio at gmail.com, craig.topper at gmail.com,
llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
spatel+llvm at rotateright.com
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).
https://godbolt.org/z/R8zyHg
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
--
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/20190320/786f92ad/attachment.html>
More information about the llvm-bugs
mailing list