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

            Bug ID: 39333
           Summary: Redundant jump table index xoring
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

template<int> int foo();
typedef int (*int_fun)();

int_fun get_fun(unsigned int x)
{
    switch(x&3)
    {
        case 0: return foo<0>;
        case 1: return foo<1>;
        case 2: return foo<2>;
        case 3: return foo<3>;
     }
    return 0;
}

Current (SVN, X86-64, -O3):
get_fun(unsigned int):                         
        and     edi, 3
        xor     edi, 2
        mov     rax, qword ptr [8*rdi + .Lswitch.table.get_fun(unsigned int)]
        ret


Prefered:
get_fun(unsigned int):
        and     edi, 3
        mov     rax, QWORD PTR CSWTCH.1[0+rdi*8]
        ret

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to