7.11 Type conversions .................................................................................................... 40
7.12 Branches and switch statements ............................................................................. 43
7.13 Loops ...................................................................................................................... 45
7.14 Functions ................................................................................................................ 48
7.15 Function parameters ............................................................................................... 50
7.16 Function return types .............................................................................................. 51
7.17 Function tail calls .................................................................................................... 51
7.18 Recursive functions ................................................................................................. 52
7.19 Structures and classes ............................................................................................ 52
7.20 Class data members (instance variables) ............................................................... 53
7.21 Class member functions (methods) ......................................................................... 54
7.22 Virtual member functions ........................................................................................ 55
7.23 Runtime type identification (RTTI) ........................................................................... 56
7.24 Inheritance .............................................................................................................. 56
7.25 Constructors and destructors .................................................................................. 56
7.26 Unions .................................................................................................................... 57
7.27 Bitfields ................................................................................................................... 57
7.28 Overloaded functions .............................................................................................. 58
7.29 Overloaded operators ............................................................................................. 58
7.30 Templates ............................................................................................................... 59
7.31 Threads .................................................................................................................. 61
7.32 Exceptions and error handling ................................................................................ 62
7.33 Other cases of stack unwinding .............................................................................. 66
7.34 Propagation of NAN and INF .................................................................................. 67
7.35 Preprocessing directives ......................................................................................... 67
7.36 Namespaces ........................................................................................................... 68
8 Optimizations in the compiler .......................................................................................... 68
8.1 How compilers optimize ............................................................................................ 68
8.2 Comparison of different compilers ............................................................................. 76
8.3 Obstacles to optimization by compiler ....................................................................... 80
8.4 Obstacles to optimization by CPU ............................................................................. 83
8.5 Compiler optimization options ................................................................................... 83
8.6 Optimization directives .............................................................................................. 85
8.7 Checking what the compiler does ............................................................................. 86
9 Optimizing memory access ............................................................................................. 89
9.1 Caching of code and data ......................................................................................... 89
9.2 Cache organization ................................................................................................... 89
9.3 Functions that are used together should be stored together ...................................... 90
9.4 Variables that are used together should be stored together ...................................... 91
9.5 Alignment of data ...................................................................................................... 92
9.6 Dynamic memory allocation ...................................................................................... 92
9.7 Data structures and container classes ...................................................................... 95
9.8 Strings .................................................................................................................... 102
9.9 Access data sequentially ........................................................................................ 103
9.10 Cache contentions in large data structures ........................................................... 103
9.11 Explicit cache control ............................................................................................ 106
10 Multithreading .............................................................................................................. 108
10.1 Simultaneous multithreading ................................................................................. 109
11 Out of order execution ................................................................................................. 110
12 Using vector operations ............................................................................................... 112
12.1 AVX instruction set and YMM registers ................................................................. 114
12.2 AVX512 instruction set and ZMM registers ........................................................... 114
12.3 Automatic vectorization ......................................................................................... 115
12.4 Using intrinsic functions ........................................................................................ 118
12.5 Using vector classes ............................................................................................. 122
12.6 Transforming serial code for vectorization ............................................................. 126
12.7 Mathematical functions for vectors ........................................................................ 128
12.8 Aligning dynamically allocated memory ................................................................. 129