[gnu.gcc.bug] GCC 1.34 core dump for 80386

seanf@UCSCC.UCSC.EDU (03/16/89)

With gcc-1.34, for the 80386 (compiled by pcc) under Xenix 2.3.1:
When I tried adding the movs instruction, defined as:

(define_insn "movstrqi"
  [(set (match_operand:BLK 0 "general_operand" "D")
		(match_operand:BLK 1 "general_operand" "S"))
   (use (match_operand:SI 2 "general_operand" "c"))
   (use (reg:SI 2))
   (use (reg:SI 4))
   (use (reg:SI 5))]
""
"repne \; movsb")

I get an abort when I try to compile the following program:

struct foo {
	char a[100];
} a,b;

main() {
	a = b;
}

Here's a trace from adb (sorry, I don't have dbx).  I also have the rtl, after
the stack trace.

Anybody have any ideas *why* it's core-dumping?

Thanks,
Sean.
---------
./cc1: running
  IOT
stopped	at	kill+0xc:	jb	_cerror
* $c
abort()	from 0x3f:0x54e9e
find_reloads(0x4198dc, 0x0, 0x0, 0x0, 0x40eb10)	from 0x3f:0x57795
reload(0x419838, 0x0, 0x0)	from 0x3f:0x1070f
rest_of_compilation(0x41def4)	from finish_function+0x62
finish_function()	from 0x3f:0x706
yyparse()	from 0x3f:0xfb96
compile_file(0x18ffee33)	from 0x3f:0x10f96
main(0x8, 0x18ffed9c, 0x18ffedc0)	from _start+0x2e


;; Function main

(note 1 0 2 "" -1)

(note 2 1 3 "" -1)

(insn 3 2 4 (parallel[ 
           (set (mem/s:BLK (symbol_ref:SI ("a")))
               (mem/s:BLK (symbol_ref:SI ("b"))))
           (use (const_int 100))
           (use (reg:SI 2))
           (use (reg:SI 4))
           (use (reg:SI 5))
       ] ) -1 (nil)
   (nil))

(note 4 3 5 "" -6)

(code_label 5 4 0 1)

meissner@bert.dg.com (Michael Meissner) (03/28/89)

In article <8903170318.AA17624@ucscc.UCSC.EDU> sco!seanf@UCSCC.UCSC.EDU writes:
| With gcc-1.34, for the 80386 (compiled by pcc) under Xenix 2.3.1:
| When I tried adding the movs instruction, defined as:
| 
| (define_insn "movstrqi"
|   [(set (match_operand:BLK 0 "general_operand" "D")
| 		(match_operand:BLK 1 "general_operand" "S"))
|    (use (match_operand:SI 2 "general_operand" "c"))
|    (use (reg:SI 2))
|    (use (reg:SI 4))
|    (use (reg:SI 5))]

In 1.34, movstr* and cmpstr* were redefined to take 4 arguments
(destination, source, length, and alignment).  Redefine your pattern
as follows:

(define_insn "movstrqi"
  [(set (match_operand:BLK 0 "general_operand" "D")
		(match_operand:BLK 1 "general_operand" "S"))
   (use (match_operand:SI 2 "general_operand" "c"))
   (use (match_operand:SI 3 "immediate_operand" "i"))
   (use (reg:SI 2))
   (use (reg:SI 4))
   (use (reg:SI 5))]

You might want to consider using clobber for the final use's.  Here is
the definition from my Motorola 88K md file that allocates the
temporary registers dynamically and defines movstrsi.

(define_expand "movstrsi"
  [(parallel [(set (mem:BLK (match_operand:BLK 0 "general_operand" ""))
		   (mem:BLK (match_operand:BLK 1 "general_operand" "")))
	      (use (match_operand:SI 2 "arith32_operand" "rI"))
	      (use (match_operand:SI 3 "int5_operand" "K"))
	      (clobber (match_dup 4))
	      (clobber (match_dup 5))
	      (clobber (match_dup 6))
	      (clobber (match_dup 7))])]
  ""
  "
{
  /* Make sure no alignment more than 4 is given */
  if (INTVAL (operands[3]) > 4)
    operands[3] = gen_rtx (CONST_INT, VOIDmode, 4);

  /* punt on variable or large moves by calling the library.  For non-int
     items, we make the threshold much smaller, since there is a good chance
     that the things may actually be aligned to a higher degree, and the
     library routine should check for that.... */

  if (GET_CODE (operands[2]) != CONST_INT ||
      (INTVAL (operands[3]) < 4 &&
       INTVAL (operands[2]) > 9 * INTVAL (operands[3])))
    {				/* hand craft a call to memcpy/bcopy */
#ifdef TARGET_MEM_FUNCTIONS
      emit_library_call (gen_rtx (SYMBOL_REF, Pmode, \"memcpy\"),
			 VOIDmode, 3,
			 XEXP (operands[0], 0), Pmode,
			 XEXP (operands[1], 0), Pmode,
			 operands[2], Pmode);
#else
      emit_library_call (gen_rtx (SYMBOL_REF, Pmode, \"bcopy\"),
			 VOIDmode, 3,
			 XEXP (operands[1], 0), Pmode,
			 XEXP (operands[0], 0), Pmode,
			 operands[2], Pmode);
#endif

      DONE;
    }

  /* peel off MEM:BLK node to get pointer */
  operands[0] = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  operands[1] = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));

  /* allocate the temps output_block_move needs */
  operands[4] = gen_reg_rtx (SImode);
  operands[5] = gen_reg_rtx (SImode);
  operands[6] = gen_reg_rtx (SImode);
  operands[7] = gen_reg_rtx (SImode);
}")


(define_insn ""
  [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r"))
	(mem:BLK (match_operand:SI 1 "register_operand" "+r")))
   (use (match_operand:SI 2 "arith32_operand" "=rI"))
   (use (match_operand:SI 3 "int5_operand" "K"))
   (clobber (match_operand:SI 4 "register_operand" "=r"))
   (clobber (match_operand:SI 5 "register_operand" "=r"))
   (clobber (match_operand:SI 6 "register_operand" "=r"))
   (clobber (match_operand:SI 7 "register_operand" "=r"))]
  ""
  "* return output_block_move (operands);")

Michael Meissner, Data General.
Uucp:		...!mcnc!rti!xyzzy!meissner		If compiles were much
Internet:	meissner@dg-rtp.DG.COM			faster, when would we
Old Internet:	meissner%dg-rtp.DG.COM@relay.cs.net	have time for netnews?