[llvm-bugs] [Bug 39174] New: Use "bt" for switch select from bitmask?

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 4 07:31:37 PDT 2018


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

            Bug ID: 39174
           Summary: Use "bt" for switch select from bitmask?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: hans at chromium.org
                CC: llvm-bugs at lists.llvm.org

For example:

bool f(int x) {
    switch (x) {
    case 0: return true;
    case 1: return true;
    case 2: return false;
    case 3: return false;
    case 4: return true;
    }
}

SimplifyCFG will generate a "table lookup" from a bitmask, and on X86_64 we end
up with:

f(int):                                  # @f(int)
# %bb.0:
        mov     al, 19
        mov     ecx, edi
        shr     al, cl
        and     al, 1
        ret


I wonder if we could get tighter code with the BT instruction.

-- 
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/20181004/655d506b/attachment.html>


More information about the llvm-bugs mailing list