On Thu, 28 May 2015, James Cowgill wrote:

> Your test case is wrong. If compiled without optimization, GCC call
> 'sqrt' from glibc instead of using the sqrt.s MIPS instruction. With
> optimization GCC will remove the call altogether. This is different to
> fortran because in fortran SQRT is a builtin intrinsic.
> 
> Try this instead (compile with -O2 -lm):
> 
> #include <math.h>
> float x = 1.1342362e-39;
> int main(void) {
>   x = sqrt(x);
>   return 0;
> }

 Use:

#include <inttypes.h>
#include <stdio.h>

int main(void)
{
        union {
                float f;
                uint32_t i;
        } x = { .f = 1.1342362e-39 }, y;

        printf("x: %08" PRIx32 ", %e\n", x.i, (double) x.f);
        fflush(stdout);
        asm volatile(
                "       sqrt.s  %0, %1"
                : "=f" (y.f) : "f" (x.f));
        printf("y: %08" PRIx32 ", %e\n", y.i, (double) y.f);
        fflush(stdout);
        return 0;
}

or suchlike to make sure the required instruction is produced (at any 
optimisation level), and to report the input and output bit patterns.  
Substitute the initialisation of `x' as required (you can assign to 
`x.f' or `x.i' as required).  No need to link against -lm.

 I have just tried this program with an R4400 (MIPS III) processor that 
does trap on denormals, and Linux 4.1.0-rc4, so emulation itself is fine:

x: 000c59ca, 1.134236e-39
y: 1f1f0ab7, 3.367842e-20

For comparison you can run the kernel with the `nofpu' parameter so that 
FPU hardware is permanently disabled and all FP instructions are emulated.

  Maciej


-- 
To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/alpine.lfd.2.11.1505281357080.21...@eddie.linux-mips.org

Reply via email to