Circuit designers can create functional units with a

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x,4),%eax Multiply by data[i] movl %eax,(%edi) Write *dest incl %edx i++ cmpl %esi,%edx Compare i:length jl .L18 If <, goto loop 1 2 3 4 5 6 7 Instruction 2 reads the value stored at dest and instruction 4 writes back to this location. This seems wasteful, since the value read by instruction 1 on the next iteration will normally be the value that has just been written. 5.6. ELIMINATING UNNEEDED MEMORY REFERENCES 219 code/opt/combine.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 /* Accumulate result in local variable */ void combine4(vec_ptr v, data_t *dest) { int i; int length = vec_length(v); data_t *data = get_vec_start(v); data_t x = IDENT; *dest = IDENT; for (i = 0; i < length; i++) { x = x OPER data[i]; } *dest = x; } code/opt/combine.c Figure 5.10: Accumulating Result in Temporary. This eliminates the need to read and write intermediate values on every loop iteration. This leads to the optimization shown as combine4 in Figure 5.10 where we introduce a temporary variable x that is used in the loop to accumulate the computed va...
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