bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gcc-4.1 with fastmath


From: Barry deFreese
Subject: gcc-4.1 with fastmath
Date: Mon, 04 Dec 2006 21:45:01 -0500
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Heya gang,

I was able to build gcc-4.1 with a crtfastmath.o by changing config.gcc to the following:

i[34567]86-*-gnu*)
       tmake_file="${tmake_file} i386/t-crtfm"
       ;;

But when running the attached test code compiled with --fast-math, I get the following:

Starting program: /devel/bdefreese/fastmath_test/test1

Program received signal SIGILL, Illegal instruction.
set_fast_math () at ../../src/gcc/config/i386/crtfastmath.c:71
71            unsigned int mxcsr = __builtin_ia32_stmxcsr ();
(gdb) bt full
#0  set_fast_math () at ../../src/gcc/config/i386/crtfastmath.c:71
       mxcsr = 16998664
       eax = 1667
       ebx = <value optimized out>
       ecx = <value optimized out>
       edx = 58980863
#1  0x08048855 in __do_global_ctors_aux ()
No symbol table info available.
#2  0x080483dd in _init ()
No symbol table info available.
#3  0x0804868f in __libc_csu_init ()
No symbol table info available.
#4  0x01068edb in __libc_start_main () from /lib/libc.so.0.3
No symbol table info available.
#5  0x08048491 in _start () at ../sysdeps/i386/elf/start.S:119
No locals.



Thanks,

Barry deFreese (aka bddebian)


#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>

#define ITERATIONS 1024

typedef struct {
        char sign;
        long frac;
        int exp;
} sdouble;

/* Warning : double's size is hardcoded here, very bad habit. This program
   is initially designed to only run on Itanium. */
sdouble cut_double (double d) {
        sdouble ret;
        long *db;

        db = (long *)&d;

        ret.sign = (*db >> 63) & 0x0000000000000001;
        ret.exp  = ((*db >> 52) & 0x00000000000007FF) - 1023;
        ret.frac = (*db )      & 0x000FFFFFFFFFFFFF;

        return ret;
}

int main (int argc, char **argv) {
        sdouble sa;
        double a;
        int i;

        a = 1;
        i = 1;

        openlog ("double_test", LOG_CONS, LOG_USER);

        syslog (LOG_USER | LOG_NOTICE, "starting");

        while (i <= ITERATIONS) {
                syslog (LOG_USER | LOG_NOTICE, "iteration #%d", i);
                a /= 2;
                sa = cut_double (a);
                printf ("iteration %d : a=(%d, %lx, %d) : ", i, sa.sign,
                        sa.frac, sa.exp);
                printf ("\n");
                i++;
        }

        exit (0);
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]