[llvm-bugs] [Bug 46315] New: Clang unnecessarily generates "movl $0, %edi" instead of "xorl %edi, %edi"

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 13 15:50:24 PDT 2020


            Bug ID: 46315
           Summary: Clang unnecessarily generates "movl $0, %edi" instead
                    of "xorl %edi, %edi"
           Product: new-bugs
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: josephcsible at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

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

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


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".

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/20200613/a9eadbe8/attachment.html>

More information about the llvm-bugs mailing list