Question: Problem 2 Suppose we recompile the C/C++ code fragment with an optimizing compiler, and get the following new MIPS code (note that the variable sum

Problem 2 Suppose we recompile the C/C++ code fragment with an optimizing compiler, and get the following new MIPS code (note that the variable sum is now allocated to a register for the duration of the loop, and does not have to be loaded from and stored to memory in each loop iteration) Optimized MIPS code Or Lw $16,$16,$0 S21,($20) #1-0 # load sum # load x[1] #sum-sum + x[1] loop:Lw S19.($18) Add $21,$21,$19 Addi S16,$16,1 Addi $18,S18,4 Sti S17,S16,10 Bne $17.$0.loop Sw S21,($20) #ptr++ # f (k10) goto loop # store sum We now run the optimized MIPS code on CPU_base from Problem la. Calculate the instruction count and CPI for each instruction type, and also the total instruction count and the number of cycles it takes the optimized MIPS code to run. How much faster is the optimized code than the original code? Problem 3: Exercise 1.5 on page 55 Problem 4: Exercise 1.6 on page 55 Problem 5: Exercise 1.8 on page 56 Problem 6: Exercise 1.10 on page 57
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
