<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 - Clang unnecessarily generates "movl $0, %edi" instead of "xorl %edi, %edi""
   href="https://bugs.llvm.org/show_bug.cgi?id=46315">46315</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang unnecessarily generates "movl $0, %edi" instead of "xorl %edi, %edi"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>josephcsible@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider this code:

void h(int, int, int, int, int);
void f(void) {
    h(0, 0, 2, 3, 1);
}

When compiled with Clang 10.0.0 on x86-64 Linux, it produces the following
assembly:

f:
        movl    $0, %edi
        xorl    %esi, %esi
        movl    $2, %edx
        movl    $3, %ecx
        movl    $1, %r8d
        jmp     h

<a href="https://godbolt.org/z/ovmjYV">https://godbolt.org/z/ovmjYV</a>

It missed the obvious optimization to use "xorl    %edi, %edi" instead of "movl
   $0, %edi".

Bizarrely, this is really sensitive to the other values passed to h. For
example, if I did "h(0, 0, 2, 3, 2)" instead of "h(0, 0, 2, 3, 1)", then it
would correctly use "xorl".</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>