https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
Bug ID: 68027 Summary: conditional statement and unnecessary register assignment Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: SztfG at yandex dot ru Target Milestone: --- C source code: int a1(int); int a2(int); int a3(int); int test1(int a) { if (a > 100) return a1(a); else if (a < 100) return a2(a); return a3(a); } ----------------------------------- Assembly output: test1: .LFB0: .cfi_startproc cmpl $100, %edi jg .L5 jne .L6 movl $100, %edi # no need to do this, eax is equal $100 at this point jmp a3 .p2align 4,,10 .p2align 3 .L6: jmp a2 .p2align 4,,10 .p2align 3 .L5: jmp a1 .cfi_endproc ----------------------------------- Tested on http://gcc.godbolt.org/ : gcc versions 4.4.7 - 5.2.0 have this problem.