Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Jump threading

From Wikipedia, the free encyclopedia
Compiler optimization of one jump directly to a second jump
Not to be confused withThreaded code.
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Jump threading" – news ·newspapers ·books ·scholar ·JSTOR
(December 2009) (Learn how and when to remove this message)

Incomputing,jump threading is acompiler optimization of one jump directly to a second jump. If the second condition is asubset orinverse of the first, it can be eliminated, or threaded through the first jump.[1] This is easily done in a single pass through the program, following acyclic chained jumps until the compiler arrives at a fixed point.

Benefits

[edit]

The primary benefit of jump threading is the reduction of the amount of dynamically executed jumps. This makes way for further optimizations as there is a decrease in the number of conditionals, which will improve performance. On average one can expect 2-3 instructions being omitted as a result from a successful removal of aruntimebranch.[2]

Examples

[edit]

The followingpseudocode demonstrates when a jump may be threaded.

   10. a = SomeNumber();   20. IF a > 10 GOTO 50   ...   50. IF a > 0 GOTO 100   ...

The jump on line 50 will always be taken if the jump on line 20 is taken. Therefore, for as long as line 100 is within the reachable range of the jump (or the size of the jump doesn't matter), the jump on line 20 may safely be modified to jump directly to line 100.

Another example shows jump threading of 2 partial overlap conditions:

voidbaz(boolx,booly,boolz){if(x&&y)bar();if(y||z)foo();}

The above can be transformed into:

voidbaz(boolx,booly,boolz){if(x&&y){bar();gotojmp;}if(y||z){jmp:foo();}}

If the first branch is taken,x andy are bothtrue (logical conjunction), hence evaluation ofexpressiony || z is not needed (logical disjunction). Therefore, a jump tolabeljmp is performed.[2]

See also

[edit]

References

[edit]
  1. ^"Optimize Options - Using the GNU Compiler Collection (GCC)".
  2. ^ab"A gentle introduction to jump threading optimizations | Red Hat Developer".developers.redhat.com. 2019-03-13. Retrieved2023-01-08.
Basic block
Loop
Data-flow
analysis
SSA-based
Code generation
Functional
Global
Other
Static analysis


Stub icon

Thiscomputer science article is astub. You can help Wikipedia byadding missing information.

Γ{\displaystyle \Gamma \!\vdash }

Thisprogramming language theory ortype theory-related article is astub. You can help Wikipedia byadding missing information.

Retrieved from "https://en.wikipedia.org/w/index.php?title=Jump_threading&oldid=1337508978"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp