This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: turning off optimization on a code segment


John Fine wrote:
In my first reply, I forgot to include the example I meant to give of where I have seen that behavior. It was a different compiler (not GCC) but the issue occurs in any efficient use of the x86 floating point stack, so I expect it occurs in GCC as well.

do
{
  *pdTime = *pdTnext;
  invoke some external function
 *pdTnext= some computation
} while ( *pdTime < *pdTnext)

On two successive passes, the exact same 80 bit value is computed for *pdTnext, but the loop doesn't end. The value stored in each of *pdTnext and *pdTime is the 64 bit round of the computed 80 bit value, and the value used for *pdTime in the comparison is that 64 bit value, but the value used for *pdTnext is the just computed 80 bit value that is still available in a register (instead of reading back the value just written). The external function keeps the compiler from tracking the value of *pdTime in a register.

I've debugged the above infinite loop a few times in different programs.

Frédéric BOIS wrote:
pifn->bOn = (*pdTime < *pdTnext);

Such a problem could be avoided by several well-known methods: a) -mfpmath=sse b) long double *pdTime, *pdTnext c) -ffloat-store (more in line with your desire to disable optimization)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]