[llvm-bugs] [Bug 37938] New: Missed opportunity for BTR instruction

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 26 04:06:31 PDT 2018


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

            Bug ID: 37938
           Summary: Missed opportunity for BTR instruction
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hello,

Code:
uint64_t btr_maybe(uint64_t x, unsigned bit) {
    return x & ~(1ULL << bit);
}


Clang -03 gives:
btr_maybe: # @btr_maybe
  mov rax, -2
  mov ecx, esi
  rol rax, cl
  and rax, rdi
  ret


But BTR instruction can be used (and GCC 8+ emits it):
btr_maybe(unsigned long, unsigned int):
  mov rax, rdi
  btr rax, rsi
  ret

-- 
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/20180626/57361181/attachment.html>


More information about the llvm-bugs mailing list