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

            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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

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

https://godbolt.org/z/ovmjYV

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to