MIPS gcc generates bogus "sw 0,0($sp)"

Greg McGary gkm@eng.ascend.com
Mon Aug 3 23:57:00 GMT 1998


The following test program:
------------------------------------------------------------------------------
struct pack {
    long l;
} __attribute__(( aligned( 1 ), packed ));

void
foo( struct pack p )
{
    if ( p.l ) {
	p.l = 0;
    }
}
------------------------------------------------------------------------------
generates this:
------------------------------------------------------------------------------
	.file	1 "sw0.c"
gcc2_compiled.:
__gnu_compiled_c:
	.text
	.align	2
	.globl	foo
	.text
	.ent	foo
foo:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, extra= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	sw	$4,0($sp)
	lw	$2,0($sp)
	#nop
	beq	$2,$0,$L3
	sw	0,0($sp)		<<<<<< should be "sw	$0,0($sp)"
$L3:
	j	$31
	.end	foo
------------------------------------------------------------------------------

combine turns this:
------------------------------------------------------------------------------
(insn 16 14 18 (set (reg:SI 81)
        (const_int 0)) 229 {movsi_internal2} (nil)
    (expr_list:REG_EQUAL (const_int 0)
        (nil)))

(insn 18 16 20 (set (mem/s:BLK (reg:SI 0 $0))
        (unspec:BLK[ 
                (reg:SI 81)
            ]  1)) 212 {movsi_usw} (nil)
    (nil))
------------------------------------------------------------------------------
into this:
------------------------------------------------------------------------------
(insn 18 16 20 (set (mem/s:BLK (reg:SI 0 $0))
        (unspec:BLK[ 
                (const_int 0)			<<<<<< here's the constant 0
            ]  1)) 212 {movsi_usw} (nil)
    (nil))
------------------------------------------------------------------------------

Shouldn't reload turn the (const_int 0) back into (reg:SI 0 $0) ??



More information about the Gcc-bugs mailing list