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

Reply via email to