study questions - optimization 1. what is an inline function. why does the code need to be available for the compiler for this IN the .c file (or via a .h file)? 2. define branch prediction. define code motion and give an example define reduction in strength and give an example. ` define what it means to share common sub-expressions define memory aliasing define register spilling define instruction pipelining 3. why is a better algorithm possibly more important than using pointers versus array references in terms of optimization? 4. give an example of an optimization blocker and explain why it would be a problem for an optimizer? 5. in terms of optimization effects, explain the trade-offs between: gcc -g gcc -O3 gcc -g -O3 6. how could you optimize the following code? void combine1(vec_ptr v, int *dest) { int i; *dest = 0; for (i = 0; i < vec_length(v); i++) { int val; get_vec_element(v, i, &val); *dest += val; } } 7. what's wrong with this code: tolower(char *s) { int i = 0; for ( i = 0; i < strlen(s); i++) { if (s[i] >= 'A' && s[i] <= 'Z') s[i] -= ('A' - 'a'); i++; } } 8. explain Amdahl's rule. explain why this rule can mean that the final speedup may not be so great. 9. if we can do multiple adds, multiple loads, and multiple multiplies, give a rough idea of what might happen with the following 2 code samples: #1 int a, b, c, z, x, y; a = b + c z = x + y #2 int a, b, c, z, x, y; a = b * c; z = x * a 10. in question 9, what will the slowest code section be (#1 or #2) and why is that likely to be the case? 11. define loop unrolling and explain WHY it might be useful as an optimization.