22007E/0 — November 1999

AMD Athlon™ Processor x86 Code Optimization

3

C Source Level Optimizations

This chapter details C programming practices for optimizing code for the AMD Athlon™ processor. Guidelines are listed in order of importance.

Ensure Floating-Point Variables and Expressions are of Type Float

For compilers that generate 3DNow!™ instructions, make sure that all floating-point variables and expressions are of type float. Pay special attention to floating-point constants. These require a suffix of “F” or “f” (for example, 3.14f) in order to be of type float, otherwise they default to type double. To avoid automatic promotion of float arguments to double, always use function prototypes for all functions that accept float arguments.

Use 32-Bit Data Types for Integer Code

U se 3 2 -b i t d a t a t y p e s fo r i n t e g e r c o d e . Co m p i le r implementations vary, but typically the following data types are included int, signed, signed int, unsigned, unsigned int, long, signed long, long int, signed long int, unsigned long, and unsigned long int.

Ensure Floating-Point Variables and Expressions are of Type Float

13

Page 29
Image 29
AMD x86 manual Source Level Optimizations, Use 32-Bit Data Types for Integer Code