25112 Rev. 3.06 September 2005

Software Optimization Guide for AMD64 Processors

Contents

Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

1.1

Intended Audience

.1

1.2

Getting Started Quickly

.1

1.3

Using This Guide

.2

1.4

Important New Terms

.4

1.5

Key Optimizations

.6

Chapter 2

C and C++ Source-Level Optimizations

.7

2.1

Declarations of Floating-Point Values

.9

2.2

Using Arrays and Pointers

10

2.3

Unrolling Small Loops

13

2.4

Expression Order in Compound Branch Conditions

14

2.5

Long Logical Expressions in If Statements

16

2.6

Arrange Boolean Operands for Quick Expression Evaluation

17

2.7

Dynamic Memory Allocation Consideration

19

2.8

Unnecessary Store-to-Load Dependencies

20

2.9

Matching Store and Load Size

22

2.10

SWITCH and Noncontiguous Case Expressions

25

2.11

Arranging Cases by Probability of Occurrence

28

2.12

Use of Function Prototypes

29

2.13

Use of const Type Qualifier

30

2.14

Generic Loop Hoisting

31

2.15

Local Static Functions

34

2.16

Explicit Parallelism in Code

35

2.17

Extracting Common Subexpressions

37

2.18

Sorting and Padding C and C++ Structures

39

2.19

Sorting Local Variables

41

Contents

iii

Page 3
Image 3
AMD 250 manual Contents