<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - A move to a specific target register is often not optimized away"
   href="http://llvm.org/bugs/show_bug.cgi?id=18602">18602</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>A move to a specific target register is often not optimized away
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jn@sirrida.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A move to a specific target register is often not optimized away.
This unnecessarily costs 2 bytes code:

int test(int x) {
  return ((x>>2) & 15) ^ ((x>>3) & 31);
  }
=> clang -O3
    movl    %edi, %eax
    shrl    $2, %eax
    andl    $15, %eax
    shrl    $3, %edi
    andl    $31, %edi
    xorl    %eax, %edi  //
    movl    %edi, %eax  // could become xorl %edi, %eax
    retq  // we need %eax here

int test(int x, int y) {
  return (((x>>2) & 15) ^ ((x<<3) & ~31)) / y;
  }
=> clang -O3
    movl    %edi, %eax
    shrl    $2, %eax
    andl    $15, %eax
    shll    $3, %edi
    andl    $-32, %edi
    orl    %eax, %edi  //
    movl    %edi, %eax  // could become orl %edi, %eax
    cltd  // we need %eax here
    idivl    %esi
    retq</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>