If-Then-Else Statements in a Loop
6-89
Optimizing Assembly Code via Linear Assembly
6.8.4
Determining the Minimum Iteration Interval
With nine instructions, the minimum iteration interval is at least 2, because a
maximum of eight instructions can be in parallel. Based on the way the depen-
dency graph in Figure 6–17 is split, five instructions are on the A side and four
are on the B side. Because none of the instructions are MPYs, all instructions
must go on the .S, .D, or .L units, which means you have a total of six
resources.
-
LDH must be on a .D unit.
-
SHL, B, and MVK must be on a .S unit.
-
The ADDs and SUB can be on the .S, .L, or .D units.
-
The AND can be on a .S or .L unit, or .D unit (’C64x only)
From Table 6–18, you can see that no one resource is used more than two
times, so the minimum iteration interval is still 2.
Table 6–18. Resource Table for If-Then-Else Code
(a) A side
(b) B side
Unit(s)
Instructions
Total/Unit
Unit(s)
Instructions
Total/Unit
.M1
0
.M2
0
.S1
SHL & B
2
.S2
MVK
1
.D1
LDH
1
.L2
CMPEQ
1
.L1, .S1, or .D1
ADD & SUB
2
.L2 or .S2
AND
1
.L2, .S2, or .D2
ADD
1
Total non-.M units
5
Total non-.M units
4
The minimum iteration interval is also affected by the total number of instruc-
tions. Because three units can perform nonmultiply operations on a given side,
a total of five instructions can be performed with a minimum iteration interval
of 2. Because only four instructions are on the B side, the minimum iteration
interval is still 2.