Intel PXA270 Optimization Manual page 51

Pxa27x processor family
Table of Contents

Advertisement

Intel XScale® Microarchitecture & Intel® Wireless MMX™ Technology Optimization
}
The code generated for the if-else portion of this code segment using branches is:
cmp
ble
mov
b
L1:
mov
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
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)
else
Using the following data:
N1
Number of cycles to execute the if_stmt assuming the use of branch instructions
B
N2
Number of cycles to execute the else_stmt assuming the use of branch instructions
B
Intel® PXA27x Processor Family Optimization Guide
if (a > 10)
return 0;
else
return 1;
r0, #10
L1
r0, #0
L2
r0, #1
50
3
+
4
×
-------- -
4
+
----------- -
=
5.5
100
2
r0, #10
if_stmt
else_stmt
.
cycles
4-3

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pxa271Pxa272Pxa273

Table of Contents