This is the mail archive of the gcc-bugs@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]

Optimization bug



Hi. Details:

gcc version 2.95.2 19991024 (release)  
Linux Mandrake 7.0 
Source code is bugs.c. It works without -funroll-loops, or if a number of
things in the source code is removed.

Command line: $g++ -v --save-temps -funroll-loops -O3 bug.c   

Output:
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/lib/gcc-lib/i586-mandrake-linux/2.95.2/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__OPTIMIZE__ -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di586 -Dpentium -D__i586 -D__i586__ -D__pentium -D__pentium__ bug.c bug.i
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /opt/gnome/include
 /z/include
 /usr/local/include
 /usr/lib/gcc-lib/i586-mandrake-linux/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /home/gerald/include
 
 /usr/lib/gcc-lib/i586-mandrake-linux/2.95.2/../../../../include/g++-3
 /usr/lib/gcc-lib/i586-mandrake-linux/2.95.2/../../../../i586-mandrake-linux/include
End of omitted list.
 /usr/lib/gcc-lib/i586-mandrake-linux/2.95.2/cc1 bug.i -quiet -dumpbase bug.c -O3 -version -funroll-loops -o bug.s
GNU C version 2.95.2 19991024 (release) (i586-mandrake-linux) compiled by GNU C
version 2.95.2 19991024 (release).
gcc: Internal compiler error: program cc1 got fatal signal 11                  

#define MACHINE_BIG_ENDIAN

int giop_tx_big_endian;

inline
void
giop_encode_ulong(unsigned long i, char* buf)
{
    if (giop_tx_big_endian) {
#ifdef MACHINE_BIG_ENDIAN
	*(unsigned long *)buf = i;
#else
	*buf++ = (i >> 24) & 0xff;
	*buf++ = (i >> 16) & 0xff;
	*buf++ = (i >> 8) & 0xff;
	*buf = i & 0xff;
#endif
    } else {
#ifdef MACHINE_BIG_ENDIAN
	*buf++ = i & 0xff;
	*buf++ = (i >> 8) & 0xff;
	*buf++ = (i >> 16) & 0xff;
	*buf = (i >> 24) & 0xff;
#else
	*(unsigned long *)buf = i;
#endif
    }
}

#define ITERATIONS (512*1024*1024)

static
double
time_giop_encode(unsigned long l)
{
    int c;
    char buf[4];

    for (c=0; c < ITERATIONS; ++c) {
	giop_encode_ulong(l, buf);
    }
}

int
main(int ac, char* av[])
{
    giop_tx_big_endian = 1; /* big endian transmission */
    time_giop_encode(0);
    return 0;
}
# 1 "bug.c"


int giop_tx_big_endian;

inline
void
giop_encode_ulong(unsigned long i, char* buf)
{
    if (giop_tx_big_endian) {

	*(unsigned long *)buf = i;






    } else {

	*buf++ = i & 0xff;
	*buf++ = (i >> 8) & 0xff;
	*buf++ = (i >> 16) & 0xff;
	*buf = (i >> 24) & 0xff;



    }
}



static
double
time_giop_encode(unsigned long l)
{
    int c;
    char buf[4];

    for (c=0; c < (512*1024*1024) ; ++c) {
	giop_encode_ulong(l, buf);
    }
}

int
main(int ac, char* av[])
{
    giop_tx_big_endian = 1;  
    time_giop_encode(0);
    return 0;
}

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