In this code register eax holds the pointer data edx

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: e for this sudden decrease in Section 5.11.1. 220 CHAPTER 5. OPTIMIZING PROGRAM PERFORMANCE Again, one might think that a compiler should be able to automatically transform the combine3 code shown in Figure 5.9 to accumulate the value in a register, as it does with the code for combine4 shown in Figure 5.10. In fact, however, the two functions can have different behavior due to memory aliasing. Consider, for example, the case of integer data with multiplication as the operation and 1 as the identity element. Let v be a vector consisting of the three elements ¾ ¿ and consider the following two function calls: combine3(v, get_vec_start(v) + 2); combine4(v, get_vec_start(v) + 2); That is, we create an alias between the last element of the vector and the destination for storing the result. The two functions would then execute as follows: Function combine3 combine4 Initial ¾¿ ¾¿ Before Loop ¾¿½ ¾¿ i=0 ¾¿¾ ¾¿ i=1 ¾¿ ¾¿ i=2 ¾¿¿ ¾¿ Final ¾¿¿ ¾ ¿ ¿¼ As shown above, combine3 accumulates its result at the...
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