https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81914
Bug ID: 81914 Summary: gcc 7.1 generates branch for code which was branchless in earlier gcc version Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bugzi...@poradnik-webmastera.com Target Milestone: --- Code: #include <stdint.h> int cmp(int64_t a, int64_t b) { return a < b ? -1 : a > b; } Above function compiled with gcc 4.5 or above and -O2 is compiled in following way. It is branchless: cmp(long, long): xor eax, eax cmp rdi, rsi mov edx, -1 setg al cmovl eax, edx ret gcc 7.1 generates different code. It has branch: cmp(long, long): cmp rdi, rsi jl .L3 setg al movzx eax, al ret .L3: mov eax, -1 ret