Bit Field Manipulation - Intel IXP45X Developer's Manual

Network processors
Table of Contents

Advertisement

®
Intel XScale
Processor—Intel
50
-------- -
1
+
100
Cost of using branches:
50
-------- -
1
+
100
As can be seen, we get better performance by using branch instructions in the above
scenario.
3.10.3.1.3
Optimizing Complex Expressions
Conditional instructions should also be used to improve the code generated for complex
expressions such as the C shortcut evaluation feature. Consider the following C code
segment:
int foo(int a, int b)
{
if (a != 0 && b != 0)
else
}
The optimized code for the if condition is:
cmp
cmpne r1, #0
Similarly, the code generated for the following C segment
int foo(int a, int b)
{
if (a != 0 || b != 0)
else
}
is:
cmp
cmpeq r1, #0
The use of conditional instructions in the above fashion improves performance by
minimizing the number of branches, thereby minimizing the penalties caused by branch
incorrect predictions. This approach also reduces the utilization of branch prediction
resources.
3.10.3.2

Bit Field Manipulation

The shift and logical operations of the IXP45X/IXP46X network processors provide a
useful way of manipulating bit fields. Bit field operations can be optimized as follows:
August 2006
Order Number: 306262-004US
®
®
IXP45X and Intel
IXP46X Product Line of Network Processors
50
×
×
-------- -
10
+
10
=
11
100
50
50
×
×
×
-------- -
-------- -
7
+
6
+
100
100
return 0;
return 1;
r0, #0
return 0;
return 1;
r0, #0
cycles
4
=
9.5
cycles
®
®
Intel
IXP45X and Intel
IXP46X Product Line of Network Processors
Developer's Manual
199

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ixp46x

Table of Contents