Intel IXP45X Developer's Manual page 197

Network processors
Table of Contents

Advertisement

®
Intel XScale
Processor—Intel
a program is relatively large compared to the size of the branch target buffer; it is often
beneficial to minimize the number of branches in a program. Consider the following C
code segment.
int foo(int a)
{
if (a > 10)
else
}
The code generated for the if-else portion of this code segment using branches is:
cmp
ble
mov
b
L1:
mov
L2:
The code generated above takes three cycles to execute the else part and four cycles
for the if-part assuming best case conditions and no branch misprediction penalties. In
the case of the IXP45X/IXP46X network processors, a branch misprediction incurs a
penalty of four cycles. If the branch is incorrectly predicted 50 percent of the time, and
if we assume that both the if-part and the else-part are equally likely to be taken, on an
average the code above takes 5.5 cycles to execute.
50
×
-------- -
4
100
If we were to use the IXP45X/IXP46X network processors to execute instructions
conditionally, the code generated for the above if-else statement is:
cmp
movgt r0, #0
movle r0, #1
The above code segment would not incur any branch misprediction penalties and would
take three cycles to execute assuming best case conditions. As can be seen, using
conditional instructions speeds up execution significantly. However, the use of
conditional instructions should be carefully considered to ensure that it does improve
performance. To decide when to use conditional instructions over branches consider the
following hypothetical code segment:
August 2006
Order Number: 306262-004US
®
®
IXP45X and Intel
IXP46X Product Line of Network Processors
return 0;
return 1;
r0, #10
L1
r0, #0
L2
r0, #1
3
+
4
----------- -
+
=
5.5
cycles
2
r0, #10
®
®
Intel
IXP45X and Intel
IXP46X Product Line of Network Processors
Developer's Manual
197

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the IXP45X and is the answer not in the manual?

This manual is also suitable for:

Ixp46x

Table of Contents