This article may be too technical for most readers to understand.(January 2024) |
Control dependency is a situation in which a program instruction executes if the previous instruction evaluates in a way that allows its execution.
An instruction B has a control dependency on a preceding instruction A if the outcome of A determines whether B should be executed or not. In the following example, the instruction has a control dependency on instruction . However, does not depend on because is always executed irrespective of the outcome of .
S1. if (a == b) S2. a = a + b S3. b = a + b
Intuitively, there is control dependence between two statements A and B if
A typical example is that there are control dependences between the condition part of an if statement and the statements in its true/false bodies.
A formal definition of control dependence can be presented as follows:
A statement is said to be control dependent on another statement iff
Expressed with the help of (post-)dominance the two conditions are equivalent to