Re: turning off optimization on a code segment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux