<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Redundant jump table index xoring"
   href="https://bugs.llvm.org/show_bug.cgi?id=39333">39333</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Redundant jump table index xoring
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>