Intel® PXA27x Processor Family
Optimization Guide
4-3
Intel XScale® Microarchitecture & Intel® Wireless MMX™ Technology Optimization
if (a > 10)
return 0;
else
return 1;
}
The code generated for the
if-else
portion of this code segment using branches is:
cmp r0, #10
ble L1
mov r0, #0
b L2
L1:
mov r0, #1
L2:
This code takes three cycles to execute the
else
statement and four cycles for the
if
statement
assuming best case conditions and no branch misprediction penalties. In the case of the Intel
XScale® Microarchitecture, a branch misprediction incurs a penalty of four cycles. If the branch is
mispredicted 50% of the time and if both the
if
statement and the
else
statement
are equally likely
to be taken, on an average the code above takes 5.5 cycles to execute.
.
Using the Intel XScale® Microarchitecture to execute instructions conditionally, the code
generated for the preceding
if
-
else
statement is:
cmp r0, #10
movgt r0, #0
movle r0, #1
The preceding code segment would not incur any branch misprediction penalties and would take
three cycles to execute assuming best case conditions. Using conditional instructions speeds up
execution significantly. However, the use of conditional instructions should be considered carefully
to ensure it improve performance. To decide when to use conditional instructions over branches,
consider this hypothetical code segment:
if (cond)
if_stmt
else
else_stmt
Using the following data:
N1
B
Number of cycles to execute the if_stmt assuming the use of branch instructions
N2
B
Number of cycles to execute the else_stmt assuming the use of branch instructions
50
100
--------- 4
3 4
+
2
------------
+
×
5.5
=
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: ......