Intel IXP45X Developer's Manual page 196

Network processors
Table of Contents

Advertisement

Intel
if (a + b)
Code generated for the if condition without using an add instruction to set condition
codes is:
;Assume r0 contains the value a, and r1 contains the value b
add
cmp
However, code can be optimized as follows making use of add instruction to set
condition codes:
;Assume r0 contains the value a, and r1 contains the value b
adds
The instructions that increment or decrement the loop counter can also be used to
modify the condition codes. This eliminates the need for a subsequent compare
instruction. A conditional branch instruction can then be used to exit or continue with
the next loop iteration.
Consider the following C code segment:
for (i = 10; i != 0; i--)
{
do something;
}
The optimized code generated for the above code segment would look like:
L6:
.
.
subs r3, r3, #1
bne
It is also beneficial to rewrite loops whenever possible so as to make the loop exit
conditions check against the value 0. For example, the code generated for the code
segment below will need a compare instruction to check for the loop exit condition.
for (i = 0; i < 10; i++)
{
do something;
}
If the loop were rewritten as follows, the code generated avoids using the compare
instruction to check for the loop exit condition.
for (i = 9; i >= 0; i--)
{
do something;
}
3.10.3.1.2
Optimizing Branches
Branches decrease application performance by indirectly causing pipeline stalls. Branch
prediction improves the performance by lessening the delay inherent in fetching a new
instruction stream. The number of branches that can accurately be predicted is limited
by the size of the branch target buffer. Since the total number of branches executed in
®
®
Intel
IXP45X and Intel
IXP46X Product Line of Network Processors
Developer's Manual
196
®
®
IXP45X and Intel
IXP46X Product Line of Network Processors—Intel XScale
r0,r0,r1
r0, #0
r0,r0,r1
.L6
®
Processor
August 2006
Order Number: 306262-004US

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Ixp46x

Table of Contents