public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Marcus Comstedt <marcus@mc.pp.se>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: optimization/5768: sh codegen leaves stuff on stack
Date: Thu, 07 Mar 2002 08:06:00 -0000	[thread overview]
Message-ID: <20020307160603.3902.qmail@sources.redhat.com> (raw)

The following reply was made to PR optimization/5768; it has been noted by GNATS.

From: Marcus Comstedt <marcus@mc.pp.se>
To: "Arati Dikey" <AratiD@kpit.com>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>,
	<amylaar@gcc.gnu.org>, <amylaar@redhat.com>, <aoliva@redhat.com>
Subject: Re: optimization/5768: sh codegen leaves stuff on stack
Date: 07 Mar 2002 16:55:45 +0100

 "Arati Dikey" <AratiD@kpit.com> writes:
 
 > hi !
 > 
 > Can you please give the details of how/where your actual program crashes
 > ?
 > My sample program worked after reversing the patch. So, how can I
 > reproduce the
 > problem you are facing ?
 > 
 > For e.g
 > What options are you giving to gcc ?
 > Where does your program crash ?
 > 
 > and whatever other details you can think of to give some insight into
 > the problem.
 
 Ok, I have now analyzed the new problem, and it's virtually the same
 as the old one.  You need a slightly more complicated function to
 trigger it though:
 
 --8<--
 
 int x[2], y[2], sz;
 
 void foo() 
 { 
   int i, n = sz;
   for(i = 0; i<n; i++)
     if(x[i]==y[i]) {
       bar();
       return; 
     }
 }
 
 --8<--
 
 Compile with the same flags as before (-O2 -fomit-frame-pointer
 -funroll-loops) and it makes the same mistake, it chains to the bar()
 function without removing the stack frame.  Although in this case the
 problem is worse, since it doesn't even restore the old value of r8.
 
 Generated code:
 
 --8<--
 	.file	"foo.c"
 	.text
 	.align 2
 	.global	_foo
 	.type	_foo,@function
 _foo:
 	mov.l	r8,@-r15
 	mov	#0,r7
 	mov.l	.L42,r1
 	mov.l	@r1,r5
 	cmp/ge	r5,r7
 	bt	.L8
 	mov	#3,r1
 	mov	r5,r2
 	and	r1,r2
 	mov	#1,r1
 	mov.l	.L43,r8
 	mov	#0,r0
 	mov.l	.L44,r6
 	cmp/ge	r5,r1
 	mov.l	.L45,r4
 	bt	.L11
 	tst	r2,r2
 	bt	.L10
 	cmp/gt	r1,r2
 	bf	.L11
 	mov	#2,r1
 	cmp/gt	r1,r2
 	bf	.L12
 	mov.l	@(r0,r8),r2
 	mov	#1,r7
 	mov.l	@r6,r1
 	mov	#4,r0
 	cmp/eq	r1,r2
 	bt	.L35
 .L12:
 	mov.l	@(r0,r8),r2
 	add	#1,r7
 	mov.l	@(r0,r6),r1
 	add	#4,r0
 	cmp/eq	r1,r2
 	bt	.L36
 .L11:
 	mov.l	@(r0,r8),r2
 	mov.l	@(r0,r6),r1
 	cmp/eq	r1,r2
 	bt	.L37
 	add	#1,r7
 	add	#4,r0
 	cmp/ge	r5,r7
 	bt	.L8
 .L10:
 	mov	r0,r3
 	add	r8,r3
 	.align 2
 .L7:
 	mov.l	@r3,r2
 	mov.l	@(r0,r6),r1
 	cmp/eq	r1,r2
 	bt	.L38
 	add	#4,r0
 	mov.l	@(r0,r6),r1
 	mov.l	@(4,r3),r2
 	add	#-4,r0
 	cmp/eq	r1,r2
 	bt	.L39
 	add	#8,r0
 	mov.l	@(r0,r6),r1
 	mov.l	@(8,r3),r2
 	add	#-8,r0
 	cmp/eq	r1,r2
 	bt	.L40
 	add	#12,r0
 	mov.l	@(r0,r6),r1
 	mov.l	@(12,r3),r2
 	add	#-12,r0
 	cmp/eq	r1,r2
 	bt	.L41
 	add	#4,r7
 	add	#16,r3
 	add	#16,r0
 	cmp/ge	r5,r7
 	bf	.L7
 .L8:
 	rts	
 	mov.l	@r15+,r8
 	.align 2
 .L35:
 	jmp	@r4
 	nop
 	.align 2
 .L36:
 	jmp	@r4
 	nop
 	.align 2
 .L37:
 	jmp	@r4
 	nop
 	.align 2
 .L38:
 	jmp	@r4
 	nop
 	.align 2
 .L39:
 	jmp	@r4
 	nop
 	.align 2
 .L40:
 	jmp	@r4
 	nop
 	.align 2
 .L41:
 	jmp	@r4
 	nop
 .L46:
 	.align 2
 .L42:
 	.long	_sz
 .L43:
 	.long	_x
 .L44:
 	.long	_y
 .L45:
 	.long	_bar
 .Lfe1:
 	.size	_foo,.Lfe1-_foo
 	.comm	_x,8,4
 	.comm	_y,8,4
 	.comm	_sz,4,4
 	.ident	"GCC: (GNU) 3.0.4"
 --8<--
 
 So it seems that the real problem remains, and the removal of the
 patch only made the illusion of fixing the problem by reducing the
 size of the stack frame to 0 in the more trivial test program.
 
 
   // Marcus
 
 


             reply	other threads:[~2002-03-07 16:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-07  8:06 Marcus Comstedt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-03-27 14:20 rth
2002-03-27 14:16 Marcus Comstedt
2002-03-25 14:06 rth
2002-03-25 10:10 rth
2002-03-06 21:36 Arati Dikey
2002-03-06 15:06 Marcus Comstedt
2002-02-23 21:47 marcus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020307160603.3902.qmail@sources.redhat.com \
    --to=marcus@mc.pp.se \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).