Intel PXA270 Optimization Manual page 52

Pxa27x processor family
Table of Contents

Advertisement

Intel XScale® Microarchitecture & Intel® Wireless MMX™ Technology Optimization
P1 Percentage of times the if_stmt is likely to be executed
P2 Percentage of times likely to incur a branch misprediction penalty
N1
Number of cycles to execute the if-else portion using conditional instructions assuming
C
N2
Number of cycles to execute the if-else portion using conditional instructions assuming
C
Use conditional instructions when:
The following example illustrates a situation in which it is better to use branches instead of
conditional instructions.
cmp
bne
add
add
add
add
add
b
L1:
sub
sub
sub
sub
sub
L2:
The CMP instruction takes one cycle to execute, the if statement takes seven cycles to execute, and
the else statement takes six cycles to execute.
If the code were changed to eliminate the branch instructions by using of conditional instructions,
the if-else statement would take 10 cycles to complete.
Assuming an equal probability of both paths being taken and that branch misprediction occur 50%
of the time, compute the costs of branch prediction versus conditional execution as:
Cost of using conditional instructions:
4-4
the if-condition to be true
the if-condition to be false
P1
100 P1
×
×
N1
-------- -
+
N2
--------------------- -
C
C
100
100
r0, #0
L1
r0, r0, #1
r1, r1, #1
r2, r2, #1
r3, r3, #1
r4, r4, #1
L2
r0, r0, #1
r1, r1, #1
r2, r2, #1
r3, r3, #1
r4, r4, #1
50
50
×
×
1
+
-------- -
10
+
-------- -
10
100
100
P1
×
N1
-------- -
+
N2
B
100
=
11
cycles
Intel® PXA27x Processor Family Optimization Guide
100 P1
P2
×
×
--------------------- -
+
-------- -
4
B
100
100

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pxa271Pxa272Pxa273

Table of Contents