4 1 fldl a st0 4 fchs st1 st0 2 fmul

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: variant, where we compute the reciprocal r2 directly rather than calling recip: code/asm/fcomp.c 3.14. *FLOATING-POINT CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 175 void test2(int denom) { double r1, r2; int t1, t2; r1 = recip(denom); /* Stored in memory */ r2 = 1.0/(double) denom; /* Stored in register */ t1 = r1 == r2; /* Compares register to memory */ do_nothing(); /* Forces register save to memory */ t2 = r1 == r2; /* Compares memory to memory */ printf("test2 t1: r1 %f %c= r2 %f\n", r1, t1 ? ’=’ : ’!’, r2); printf("test2 t2: r1 %f %c= r2 %f\n", r1, t2 ? ’=’ : ’!’, r2); } code/asm/fcomp.c Once again we get t1 equal to 0—the double-precision value in memory computed by recip is compared to the extended-precision value computed directly. A second method is to disable compiler optimization. This causes the compiler to store every intermediate result on the main program stack, ensuring that all values are converted to double precision. However, this leads to a significant loss of performance. Aside: Why should we be concerned about these inconsistencies? As we will discuss in Chapter 5, one of the fundamental principles of optimizing compilers is that programs s...
View Full Document

Ask a homework question - tutors are online