4-4
Intel® PXA27x Processor Family
Optimization Guide
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
C
Number of cycles to execute the
if
-
else
portion using conditional instructions assuming
the
if
-condition to be true
N2
C
Number of cycles to execute the
if
-
else
portion using conditional instructions assuming
the
if
-condition to be false
Use conditional instructions when:
The following example illustrates a situation in which it is better to use branches instead of
conditional instructions.
cmp r0, #0
bne L1
add r0, r0, #1
add r1, r1, #1
add r2, r2, #1
add r3, r3, #1
add r4, r4, #1
b L2
L1:
sub r0, r0, #1
sub r1, r1, #1
sub r2, r2, #1
sub r3, r3, #1
sub r4, r4, #1
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:
N
1
C
P
1
100
---------
×
N
2
C
100
P
1
–
100
----------------------
×
N
1
B
P
1
100
---------
×
N
2
B
100
P
1
–
100
----------------------
×
P
2
100
--------- 4
×
+
+
≤
+
1
50
100
--------- 10
×
50
100
--------- 10
×
+
+
11
=
cycles
Содержание PXA270
Страница 1: ...Order Number 280004 001 Intel PXA27x Processor Family Optimization Guide April 2004...
Страница 10: ...x Intel PXA27x Processor Family Optimization Guide Contents...
Страница 20: ...1 10 Intel PXA27x Processor Family Optimization Guide Introduction...
Страница 30: ...2 10 Intel PXA27x Processor Family Optimization Guide Microarchitecture Overview...
Страница 48: ...3 18 Intel PXA27x Processor Family Optimization Guide System Level Optimization...
Страница 114: ...5 16 Intel PXA27x Processor Family Optimization Guide High Level Language Optimization...
Страница 122: ...6 8 Intel PXA27x Processor Family Optimization Guide Power Optimization...
Страница 143: ...Intel PXA27x Processor Family Optimization Guide Index 5 Index...
Страница 144: ......