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]

wrong alpha code with profile



Current egcs-2.91.42 19980623 produces wrong code on alphaev56-unknown-linux-gnu
when compiling with -p -O2.

Register 28 is destroyed for mcount call.

$legal_move..ng:
        lda $30,-640($30)
        lda $28,stp
        ...
	lda $28,_mcount
	jsr $28,($28),_mcount
	ldq $2,0($28)             <--- crash, compiler wanted to access *stp,
                                       but $28 is no longer stp.
        ... 



typedef struct {
      short     amzug;      
      short       wta;      
      short       wth;      
      short       wki;      
      short       sta;      
      short       sth;      
      short       ski;      
      short    anzahl;             
      short   w_k_ort;             
      short   s_k_ort;             
      short        ep;             
      short        vf;             
      short   glo_bew;             
      short  horizont;             
      short  last_feld;            
                              } STELLUNG;

extern STELLUNG *stp; 

short  legal_move(char  **zl,short  *as,short  *an)
{
STELLUNG temp;
short  a;
char  *ap,*ap2;
short  anz,anz_s,anz_n,anzahl,schach;
short  amzug = stp->amzug;
char  zugl[512 ];

        ap =  zugl + 256 ;
        anz = zuggenerator(&ap,&anz_s,&anz_n);

        anzahl = 0;
        ap2 = *zl;

        for(a=0;a<anz;a++)
        {

                temp = *stp;
                zugausfuehrung(*ap,*(ap+1));

                switch (amzug)
                {
                        case 1  : schach = kis_w();
                                  break;
                        case 129  : schach = kis_s();
                                  break;
                        default : string_alert("ERROR in legal_move");
                }

                if (!schach)
                {
                        *ap2++=*ap++;
                        *ap2++=*ap++;
                        anzahl++;
                }
                else    
		{
		        ap+=2;
		}
                switch (amzug)
                {
                        case 1  :
                                rueck_w(*(ap-2),*(ap-1));
                                break;
                        case 129  :
                                rueck_s(*(ap-2),*(ap-1));
                                break;
                }
                *stp = temp;
        }
        *as = anzahl;*an=0;
        return anzahl;
}

H
=================================================================================


	.file	1 "t.c"
	.set noat
	.set noreorder
	.arch ev56
	nop
.section	.rodata
$LC0:
	.ascii "ERROR in legal_move\0"
.text
	.align 5
	.globl legal_move
	.ent legal_move
legal_move:
	.frame $30,640,$26,0
	.mask 0x400fe00,-640
	ldgp $29,0($27)
$legal_move..ng:
	lda $30,-640($30)
	lda $28,stp
	stq $9,8($30)
	lda $1,352($30)
	stq $10,16($30)
	bis $16,$16,$9
	stq $11,24($30)
	lda $16,616($30)
	stq $12,32($30)
	bis $31,$31,$11
	stq $15,56($30)
	bis $31,$31,$12
	stq $17,624($30)
	stq $18,632($30)
	lda $17,608($30)
	stq $26,0($30)
	lda $18,610($30)
	stq $13,40($30)
	stq $14,48($30)
	.prologue 1
.data
	.align 3
$LP1:
	.quad 0
.text
	lda $28,_mcount
	jsr $28,($28),_mcount
	ldq $2,0($28)
	stq $1,616($30)
	ldwu $3,0($2)
	sextw $3,$10
	jsr $26,zuggenerator
	ldgp $29,0($26)
	sextw $0,$15
	ldq $9,0($9)
	cmplt $31,$15,$1
	beq $1,$L3
	cmpeq $10,129,$14
	cmpeq $10,1,$10
	.align 4
$L5:
	lda $28,stp
	ldq $24,616($30)
	ldq $1,0($28)
	ldq_u $7,8($1)
	ldq_u $8,16($1)
	ldq_u $5,23($1)
	ldq_u $6,0($1)
	and $1,7,$2
	extqh $7,$1,$4
	extqh $8,$1,$3
	cmoveq $2,0,$4
	extqh $5,$1,$5
	cmoveq $2,0,$3
	cmoveq $2,0,$5
	ldwu $23,28($1)
	ldwu $22,24($1)
	ldwu $2,26($1)
	extql $6,$1,$6
	extql $7,$1,$7
	bis $6,$4,$6
	extql $8,$1,$8
	bis $7,$3,$7
	bis $8,$5,$8
	stq $6,64($30)
	stq $7,72($30)
	stq $8,80($30)
	stw $22,88($30)
	stw $2,90($30)
	stw $23,92($30)
	ldbu $17,1($24)
	ldbu $16,0($24)
	sextb $17,$17
	sextb $16,$16
	jsr $26,zugausfuehrung
	ldgp $29,0($26)
	bne $10,$L7
	bne $14,$L8
	br $31,$L9
$L7:
	jsr $26,kis_w
	ldgp $29,0($26)
	sextw $0,$13
	br $31,$L6
$L8:
	jsr $26,kis_s
	ldgp $29,0($26)
	sextw $0,$13
	br $31,$L6
$L9:
	lda $16,$LC0
	jsr $26,string_alert
	ldgp $29,0($26)
$L6:
	bne $13,$L11
	ldq $2,616($30)
	addq $12,1,$1
	sextw $1,$12
	ldbu $3,0($2)
	addq $2,1,$2
	stb $3,0($9)
	addq $2,1,$4
	stq $2,616($30)
	addq $9,1,$9
	ldbu $1,0($2)
	stb $1,0($9)
	stq $4,616($30)
	addq $9,1,$9
	br $31,$L12
$L11:
	ldq $1,616($30)
	addq $1,2,$1
	stq $1,616($30)
$L12:
	bne $10,$L14
	bne $14,$L15
	br $31,$L13
$L14:
	ldq $1,616($30)
	ldbu $17,-1($1)
	ldbu $16,-2($1)
	sextb $17,$17
	sextb $16,$16
	jsr $26,rueck_w
	ldgp $29,0($26)
	br $31,$L13
$L15:
	ldq $1,616($30)
	ldbu $17,-1($1)
	ldbu $16,-2($1)
	sextb $17,$17
	sextb $16,$16
	jsr $26,rueck_s
	ldgp $29,0($26)
$L13:
	lda $28,stp
	ldq $5,80($30)
	ldq $7,72($30)
	ldq $22,64($30)
	ldq $2,0($28)
	ldl $23,88($30)
	ldwu $25,92($30)
	addq $11,1,$24
	ldq_u $1,23($2)
	insqh $5,$2,$3
	ldq_u $6,0($2)
	insqh $7,$2,$4
	mskqh $1,$2,$1
	addq $2,24,$8
	bis $1,$3,$1
	insql $5,$2,$5
	stq_u $1,23($2)
	bis $4,$5,$4
	insqh $22,$2,$3
	insql $7,$2,$7
	stq_u $4,16($2)
	bis $3,$7,$3
	insql $22,$2,$22
	mskql $6,$2,$6
	stq_u $3,8($2)
	bis $6,$22,$6
	stq_u $6,0($2)
	ldq_u $1,27($2)
	ldq_u $3,24($2)
	inslh $23,$8,$4
	msklh $1,$8,$1
	bis $1,$4,$1
	insll $23,$8,$23
	mskll $3,$8,$3
	stq_u $1,27($2)
	bis $3,$23,$3
	stq_u $3,24($2)
	sextw $24,$11
	stw $25,28($2)
	cmplt $11,$15,$1
	bne $1,$L5
$L3:
	ldq $28,624($30)
	bis $12,$12,$0
	stw $12,0($28)
	ldq $28,632($30)
	stw $31,0($28)
	ldq $26,0($30)
	ldq $9,8($30)
	ldq $10,16($30)
	ldq $11,24($30)
	ldq $12,32($30)
	ldq $13,40($30)
	ldq $14,48($30)
	ldq $15,56($30)
	lda $30,640($30)
	ret $31,($26),1
	.end legal_move
	.ident	"GCC: (GNU) egcs-2.91.42 19980623 (gcc2 ss-980502 experimental)"



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