This is the mail archive of the gcc@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: Why is floor() only compiled to roundsd when using -funsafe-math-optimizations?


On 26 January 2015 at 23:50, Fredrik Tolf <fredrik@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.


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