324_Book

# Only when the value in a register is written to

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: that uses eight-way loop unrolling: 5.9. CONVERTING TO POINTER CODE 239 code/opt/combine.c 1 2 3 4 5 6 7 8 9 10 11 12 /* Accumulate in local variable, pointer version */ void combine4p(vec_ptr v, data_t *dest) { int length = vec_length(v); data_t *data = get_vec_start(v); data_t *dend = data+length; data_t x = IDENT; for (; data &lt; dend; data++) x = x OPER *data; *dest = x; } code/opt/combine.c (a) Pointer version of combine4. code/opt/combine.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 /* Unroll loop by 3, pointer version */ void combine5p(vec_ptr v, data_t *dest) { data_t *data = get_vec_start(v); data_t *dend = data+vec_length(v); data_t *dlimit = dend-2; data_t x = IDENT; /* Combine 3 elements at a time */ for (; data &lt; dlimit; data += 3) { x = x OPER data[0] OPER data[1] OPER data[2]; } /* Finish any remaining elements */ for (; data &lt; dend; data++) { x = x OPER data[0]; } *dest = x; } code/opt/combine.c (b) Pointer version of combine5 Figure 5.22: Converting Array Code to Pointer Code. In some cases, this can lead to improved perform...
View Full Document

## This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online