In: Computer Science
Use the Compiler Explorer with the MIPS compiler to compile the following C code. Assuming this function is called with the parameter n = 5…
int summarize(int n) { int sum = 0; for (int i = 0; i < n; i++) { sum += i; } return sum; }
c) Compile the code using the ARM gcc 8.2 compiler. Add the –O1 compiler option, which asks the compiler to optimize for speed (at least to one level). What is the dynamic instruction count of this routine now in ARM instructions?
Compiler explorer is an online tool that is used to run c or c ++ or code in any other language and convert it into assembly(MIPS) instructions.
below i am giving you the snapshots of how to use it and how you will compute your answer.
1. Overview
2. WRITE CODE AND FIND ITS EQUIVALENT ASSEMBLY CODE
3. OPTIMIZATION USING -O1 OPTION
Previously , the dynamic instruction count was 25 and after optimization , the instruction count become 11 .
thank you !!
for any query feel free to ask in commet section .
if you like the answer please give a like.