Intel XScale® Microarchitecture & Intel® Wireless MMX™ Technology Optimization
•
Cost of using branches:
Users get better performance by using branch instructions in this scenario.
4.2.3
Optimizing Complex Expressions
Using conditional instructions improves the code generated for complex expressions such as the C
shortcut evaluation feature. The use of conditional instructions in this fashion improves
performance by minimizing the number of branches, thereby minimizing the penalties caused by
branch misprediction.
int foo(int a, int b){
The optimized code for the if condition is:
cmp
cmpne r1, #0
Similarly, the code generated for this C segment:
int foo(int a, int b){
is:
cmp
cmpeq r1, #0
This approach also reduces the utilization of branch prediction resources.
Intel® PXA27x Processor Family Optimization Guide
50
50
×
×
1
+
-------- -
7
+
-------- -
6
+
100
100
if (a!= 0 && b!= 0)
return 0;
else
return 1;
}
r0, #0
if (a!= 0 || b!= 0)
return 0;
else
return 1;
}
r0, #0
50
×
-------- -
4
=
9.5
cycles
100
4-5