Jump to content

Jump threading

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Citation bot (talk | contribs) at 02:24, 5 April 2022 (Add: title. Changed bare reference to CS1/2. | Use this bot. Report bugs. | Suggested by BrownHairedGirl | Linked from User:BrownHairedGirl/Articles_with_bare_links | #UCB_webform_linked 1541/2840). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, jump threading is a compiler optimization of one jump directly to a second jump. If the second condition is a subset or inverse 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.

Example

The following pseudocode 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.

See also

References

  1. ^ "Optimize Options - Using the GNU Compiler Collection (GCC)".