The following C code sets the diagonal elements of one of our fixed-size arrays to val: When

Question:

The following C code sets the diagonal elements of one of our fixed-size arrays to val:

/* Set all diagonal elements to val */ void fix_set_diag(fix_matrix A, int val) { } long i; for (i 0; i

When compiled with optimization level -01, GCC generates the following assembly code:

1 fix_set_diag: 2 3 4 5 6 7 8 void A in %rdi, val in %rsi movl $0, %eax fix_set_diag(fix_matrix A, int val)

Create a C code program fix_set_diag_opt that uses optimizations similar to those in the assembly code, in the same style as the code in Figure 3.37(b). Use expressions involving the parameter N rather than integer constants, so that your code will work correctly if N is redefined.

Figure 3.37(b)

(b) Optimized C code 2 3 4 50 6 8 9 10 L= 11 12 13 /* Compute i,k of fixed matrix product */ int

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems A Programmers Perspective

ISBN: 9781292101767

3rd Global Edition

Authors: Randal E. Bryant, David R. O'Hallaron

Question Posted: