Software Optimization Guide for AMD64 Processors

25112 Rev. 3.06 September 2005

To generalize the example in Listing 8 further for multiple-constant control code, more work may be needed to create the proper outer loop. Enumeration of the constant cases reduces this to a simple switch statement.

Listing 9.

for (i...) {

 

if (CONSTANT0) {

 

DoWork0(i);

// Does not affect CONSTANT0 or CONSTANT1.

}

 

else {

 

DoWork1(i);

// Does not affect CONSTANT0 or CONSTANT1.

}

 

if (CONSTANT1) {

 

DoWork2(i);

// Does not affect CONSTANT0 or CONSTANT1.

}

 

else {

 

DoWork3(i);

// Does not affect CONSTANT0 or CONSTANT1.

}

 

}

 

32

C and C++ Source-Level Optimizations

Chapter 2

Page 48
Image 48
AMD 250 manual Listing