> > generates the same output and same assembly
> > for both casts.  can anyone explain what this pragma
> > is supposed to do?
> 
> it changes the rounding mode from the standard
> truncate to integer (expensive on a 387) to
> round to nearest (incorrect but cheap).

sure enough.  here's timings in µsec for 1<<20 cycles

                        slow    fast    factor
amd64 (2.0ghz)          82717   2873    29
xeon 5000 (1.6ghz)      17595   1963    9
core i7 (2.6ghz)                4734    1185    4

>        #pragma fpround on
>                print("%d\n", (int)d);
>        #pragma fpround 0
>                print("%d\n", (int)d);
> 
> your examples compiles to the same code in both
> cases because the rounding mode is only consulted
> during code generation, which happens at the
> function's final }.  you'd need to write two different
> functions to demonstrate the difference.

ah.  that escaped me.  thanks.  it would be good to
document somwhere.  would updating /sys/doc/compiler.ms
be a really bad idea?

- erik

Reply via email to