View Single Post
Old 2005-07-27, 16:08   #4
R.D. Silverman
R.D. Silverman's Avatar
Nov 2003

1D2416 Posts

Originally Posted by akruppa
What does the round_double1() function do? Is that the asm function to convert a double to an int we discussed in the other thread?

My initial guess is that the compiler keeps lower_midpt on top of the cpu stack and, since it doesn't know that round_double1() works on that stack, rearranges the opcodes so that the first if() ends up comparing e to the argument of the lower_midpt() function.

I'd need to take a look at the asm output for this code snippet.

Yes. round_double1() is the function discussed earlier.

I am not sure if your explanation is right, or if somehow fistp resets
the FPU control word somehow..

Adding finit to round_double1() fixes the problem. I wish there were
a way to avoid it, since finit is expensive.

I am going to try popping the stack by fistp rather than fist

R.D. Silverman is offline   Reply With Quote