[gnu.gcc.bug] asm vs. -O ?

schwartz@shire.cs.psu.edu (Scott Schwartz) (07/05/89)

The following makes gcc-1.35 dump core when invoked with -O:

/* -*- C -*- */
typedef unsigned long ulong;

inline void quot_rem_64 (ulong arg1, ulong arg2, ulong arg3, 
			 ulong *arg4, ulong *arg5)
{
  register ulong upper = 0, lower = arg1;
  asm ("mulul %2, %0:%1" : 
       "=d" (upper), "=d" (lower) :  
       "dmn" (arg2), "0" (upper), "1" (lower));
  asm ("divul %2, %0:%1" :
       "=d" (upper), "=d" (lower) :  
       "dmn" (arg3), "0" (upper), "1" (lower));
  *arg4 = lower;
  *arg5 = upper;
}

main ()
{
  register ulong a = ~0, b = 4, c = 8;
  ulong d, e;
  
  quot_rem_64 (a, b, c, &d, &e);

  printf ("%u * %u / %u = %u, %u\n", a, b, c, d, e);
}

psusun03% gcc -v -O qr.c
gcc version 1.35
 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 qr.c /tmp/cca03707.cpp
GNU CPP version 1.35
 /usr/local/lib/gcc-cc1 /tmp/cca03707.cpp -quiet -dumpbase qr.c -O -version -o /tmp/cca03707.s
GNU C version 1.35 (68k, MIT syntax) compiled by CC.
gcc: Program cc1 got fatal signal 11.

psusun03% dbx /usr/local/lib/gcc-cc1
Reading symbolic information...
Read 47159 symbols
(dbx) where
canon_hash(x = 0xbe2cc, mode = SImode), line 1404 in "cse.c"
cse_insn(insn = 0xbe228), line 2915 in "cse.c"
cse_basic_block(from = 0xbdf70, to = (nil)), line 3654 in "cse.c"
cse_main(f = 0xbdf70, nregs = 63), line 3614 in "cse.c"
rest_of_compilation(decl = 0xc5e08), line 1322 in "toplev.c"
finish_function(), line 3647 in "c-decl.c"
yyparse(), line 230 in "c-parse.y"
compile_file(name = 0xefffaf7 "/tmp/cca03707.cpp"), line 1019 in "toplev.c"
main(argc = 9, argv = 0xefffa68, envp = 0xefffa90), line 1795 in "toplev.c"
(dbx) quit
-- 
Scott Schwartz		<schwartz@shire.cs.psu.edu>