Skip to content

Unnecessary mov eax, eax generated only if there is a conditional branch. #167795

@ruriww

Description

@ruriww

https://godbolt.org/z/48scbhEKo

Code

int eax(); unsigned long long x(int in) { in |= eax(); if (in < 0) { while (true) {} } return (unsigned long long)(unsigned)in; } unsigned long long y(int in) { in |= eax(); return (unsigned long long)(unsigned)in; }

Assembly

x(int):  push rbx  mov ebx, edi  call eax()@PLT  or eax, ebx  js .LBB0_1  mov eax, eax ; <---  pop rbx  ret .LBB0_1:  jmp .LBB0_1 y(int):  push rbx  mov ebx, edi  call eax()@PLT  or eax, ebx  pop rbx  ret```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions