[Bug target/82516] New: Optimize jmp chain
antoshkka at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Oct 11 10:56:00 GMT 2017
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"
More information about the Gcc-bugs
mailing list