Question 1: Why would a compiler likely not change
for(i=0; i<strlen(s); i+=1)
x += s[i];
into
int N = strlen(s);
for(i=0; i<N; i+=1)
x += s[i];
Question 2: If function baz
contains an invocation to function foo
inside of a loop, and that is the only place foo
is invoked in the code,
Question 3: Which of the following will (almost) never make code slower?
Select all that apply
Question 4: Which of the following will generally make code harder to read and maintain?
Select all that apply
Question 5: If a functional unit has issue 2, latency 5, capacity 1, what is the best possible improvement that could be gained by exploiting its parallelism capabilities? Answer with a speedup number (such as 1
if no benefit is possible or 7.5
if code could be made 7.5 times faster)
Select all that apply