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: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: andrea.dibia...@gmail.com, craig.top...@gmail.com,
                    llvm-bugs@lists.llvm.org, llvm-...@redking.me.uk,
                    spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to