https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83123
Bug ID: 83123 Summary: Int compare - different asm code for different return type Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bugzi...@poradnik-webmastera.com Target Milestone: --- int test1(int a, int b) { return (a < 0) && (b < 0); } bool test2(int a, int b) { return (a < 0) && (b < 0); } This produces following code, when compiled with -O2. For some reason 2nd function performs shifts first, then and. This is not necessary, you can and first, then shift. The same issue is for checking if any of numbers is negative - or can be executed first, then shift. test1(int, int): and esi, edi mov eax, esi shr eax, 31 ret test2(int, int): mov eax, edi shr esi, 31 shr eax, 31 and eax, esi ret