[llvm-bugs] [Bug 38938] New: [X86][BMI] Pointer arithmetic prevents BEXTR lowering

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 13 10:34:46 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38938

            Bug ID: 38938
           Summary: [X86][BMI] Pointer arithmetic prevents BEXTR lowering
           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: craig.topper at gmail.com, lebedev.ri at gmail.com,
                    llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com

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

-- 
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/20180913/b9a2548a/attachment.html>


More information about the llvm-bugs mailing list