[gnu.gcc.bug] Nasty bugs in asm

mike@TURING.UNM.EDU (Michael I. Bushnell) (11/08/88)

The following occurs on GCC version 1.30 running on a vax under 4.3
BSD.  

GCC doesn't seem to understand the clobber syntax too well: Here's the
test file:

--------------------------
static inline
bcopy (src, dst, length)
     register int src, dst, length;
{
  asm volatile ("movc3 %0,(%1),(%2)"
		: /* no outputs */
		: "g" (length), "g" (src), "g" (dst)
	        /*: "r0","r1","r2","r3", "r4", "r5"*/); 
}

/* Note the COMMENTED out clobbered registers... */

test()
{
  int a, b, c;
  
  bcopy(a, b, c);
}
-------------------------------


This compiles to

-------------------------------
#NO_APP
.text
	.align 1
.globl _test
_test:
	.word 0x0
#APP
	movc3 r2,(r0),(r1)
#NO_APP
	ret
-----------------------------

Which is correct. (except that registers might get overrun in more
complicated uses of bcopy). 


Now, if the comment is removed from around the clobber note, we get
the following assembly output:

-----------------------------
#NO_APP
.text
	.align 1
.globl _test
_test:
	.word 0x0
	ret
-----------------------------

GCC seems to have forgotten to output the asm at all!

The RTL of the bad case (dumped right after rtl generation with -dr)
is (with the error indicated prefixed by ";;;;;"):


-----------------------------

;; Function bcopy

;; (integrable)

(note 1 0 2 "" -1)

(insn 2 1 3 (set (reg/v:SI 16)
       (mem:SI (plus:SI (reg:SI 12)
               (const_int 4)))) -1 (nil)
   (expr_list:SI (mem:SI (plus:SI (reg:SI 12)
               (const_int 4)))
       (nil)))

(insn 3 2 4 (set (reg/v:SI 17)
       (mem:SI (plus:SI (reg:SI 12)
               (const_int 8)))) -1 (nil)
   (expr_list:SI (mem:SI (plus:SI (reg:SI 12)
               (const_int 8)))
       (nil)))

(insn 4 3 5 (set (reg/v:SI 18)
       (mem:SI (plus:SI (reg:SI 12)
               (const_int 12)))) -1 (nil)
   (expr_list:SI (mem:SI (plus:SI (reg:SI 12)
               (const_int 12)))
       (nil)))

(note 5 4 6 "" -1)

;;;;;RIGHT HERE!!!!
;;;;; THIS IS WHERE THE ASM STATEMENT SHOULD GO BUT DIDN'T!!!!
;;;;;

(insn 6 5 8 (parallel[ 
           (clobber (reg 5))
           (clobber (reg 4))
           (clobber (reg 3))
           (clobber (reg 2))
           (clobber (reg 1))
           (clobber (reg 0))
       ] ) -1 (nil)
   (nil))

(jump_insn 8 6 9 (return) -1 (nil)
   (nil))

(code_label 9 8 0 2)

;; Function test

(note 1 0 2 "" -1)

(note 2 1 3 "" -2)

(note 3 2 4 "" -2)

(insn 4 3 5 (set (reg:SI 19)
       (reg/v:SI 16)) -1 (nil)
   (nil))

(insn 5 4 6 (set (reg:SI 20)
       (reg/v:SI 17)) -1 (nil)
   (nil))

(insn 6 5 7 (set (reg:SI 21)
       (reg/v:SI 18)) -1 (nil)
   (nil))

(insn 7 6 8 (set (reg:SI 23)
       (reg:SI 13)) -1 (nil)
   (nil))

(note 8 7 9 "" -1)

;;;;; AND AGAIN!!  HERE IT ISN'T *AGAIN*

(insn/i 9 8 10 (parallel[ 
           (clobber (reg 5))
           (clobber (reg 4))
           (clobber (reg 3))
           (clobber (reg 2))
           (clobber (reg 1))
           (clobber (reg 0))
       ] ) -1 (nil)
   (nil))

(jump_insn 10 9 11 (set (pc)
       (label_ref 13)) -1 (nil)
   (nil))

(barrier 11 10 12)

(code_label 12 11 13 3)

(code_label 13 12 14 4)

(note 14 13 15 "" -3)

(note 15 14 16 "" -3)

(note 16 15 17 "" -6)

(jump_insn 17 16 0 (return) -1 (nil)
   (nil))
--------------------------------


This is nasty...I think it ought to be fixed....

If it were...I could continue working...


			--Mike