This preview shows page 1. Sign up to view the full content.
Unformatted text preview: only a factor of three. A second drawback of loop unrolling is that it increases the amount of object code generated. The object code for combine4 requires 63 bytes, whereas the object code with the loop unrolled by a factor of 16 238 CHAPTER 5. OPTIMIZING PROGRAM PERFORMANCE requires 142 bytes. In this case, that seems like a small price to pay for code that runs nearly twice as fast. In other cases, however, the optimum position in this time-space tradeoff is not so clear. 5.9 Converting to Pointer Code
Before proceeding further, let us attempt one more transformation that can sometimes improve program performance, at the expense of program readability. One of the unique features of C is the ability to create and reference pointers to arbitrary program objects. Pointer arithmetic, in fact, has a close connection to array referencing. The combination of pointer arithmetic and referencing given by the expression *(a+i) is exactly equivalent to the array reference a[i]. At times, we can improve the performance of a program by using pointers rather than arrays. Fig...
View Full Document
- Spring '10
- The American