|
1. X = 1
2. Y = 2
3. if Y < T then
4. X = 2
5. else
6. Y = X
7. endif
8. Z = X + Y |
Find out data dependence for X.
- Definition of X in 1 and 4
- Use of X at 6 and 8
Therefore
Conditionals in Loops
- Statements that can’t be executed on the same iteration cannot be involved in a loop-independent dependence
- Conditionals do not affect loop carried dependence
1. for i = 2 to 9 do
2. if a(i) > 0 then
3. a(i) = b(i-1) + 1
4. else
5. b(i) = a(i) * 2
6. endif
7. endfor |
Note:  |
|
|