https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82516
Bug ID: 82516 Summary: Optimize jmp chain Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- Following code unsigned bar(); unsigned foo1(int i) { if (i < 0) { return bar(); } return i; } at -O2 produces the assembly: foo1(int): test edi, edi js .L4 <== use "js bar()" instead mov eax, edi ret .L4: jmp bar() <== this could be removed Generally speaking, any chain of jmps could be optimized to directly jumping to a target. For example js A A: jmp B B: jmp C could be optimized to "js C"