On 26 January 2015 at 23:50, Fredrik Tolf <fred...@dolda2000.com> wrote: > Dear list, > > Consider the following small program: > > #include <math.h> > #include <stdio.h> > #include <stdlib.h> > > int main(int argc, char **argv) > { > double a; > > a = strtod(argv[0], NULL); > printf("%f\n", floor(a)); > return(0); > } > > When compiling this with a -march that supports the roundsd instruction, the > floor() call seems to only be compiled to such an instruction if > -funsafe-math-optimizations is specified. > > Why is this? I notice the glibc's floor() implementation (for SSE4.1-enabled > processors) consists of only this instruction, so barring a bug in glibc, > that would seem to imply to me the roundsd is IEEE-compliant and safe. Why > does GCC consider it unsafe?
I asked the same thing: https://gcc.gnu.org/ml/gcc-help/2014-01/msg00051.html Jay.