Bug 16294 - [4.0 Regression] Missed delay slot scheduling opportunity
: [4.0 Regression] Missed delay slot scheduling opportunity
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: rtl-optimization
: 4.0.0
: P2 normal
: 4.0.0
Assigned To: Eric Botcazou
:
: missed-optimization, patch
:
:
  Show dependency treegraph
 
Reported: 2004-06-30 11:02 UTC by Eric Botcazou
Modified: 2004-09-13 14:15 UTC (History)
1 user (show)

See Also:
Host: sparc*-*-*
Target: sparc*-*-*
Build: sparc*-*-*
Known to work:
Known to fail:
Last reconfirmed: 2004-07-07 13:44:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Botcazou 2004-06-30 11:02:07 UTC
The RTL prologue/epilogue patch for SPARC:

   http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01049.html

introduced a regression with regard to delay slot scheduling and branches.


For the testcase:

void f (double*a, int m)
{
  int j;

  for(j=0; j<m; j++)
    a[j]=1;
}

compiled at -O2 -mcpu=ultrasparc, the diff looks like:

@@ -12,10 +12,9 @@
 	.type	f, #function
 	.proc	04
 f:
-	!#PROLOGUE# 0
-	!#PROLOGUE# 1
 	cmp	%o1, 0
-	ble,pn	%icc, .LL5
+	ble,pn	%icc, .LL8
+	nop
 	sethi	%hi(.LLC0), %g1
 	mov	0, %o5
 	ldd	[%g1+%lo(.LLC0)], %f8
@@ -25,9 +24,9 @@
 	cmp	%o1, %o5
 	bg,pt	%icc, .LL4
 	std	%f8, [%o0+%g1]
-.LL5:
-	retl
-	nop
+.LL8:
+	jmp	%o7+8
+	 nop
 	.size	f, .-f
 	.section	".rodata"
 	.align 8


For testsuite/gcc.c-torture/compile/990517-1.c, the diff is:

@@ -7,9 +7,7 @@
 	.type	sdbm__splpage, #function
 	.proc	020
 sdbm__splpage:
-	!#PROLOGUE# 0
 	save	%sp, -1168, %sp
-	!#PROLOGUE# 1
 	add	%fp, -1056, %l6
 	mov	%i0, %o1
 	mov	1024, %o2
@@ -26,7 +24,8 @@
 	mov	1024, %o2
 	ldsh	[%fp-1056], %l4
 	cmp	%l4, 0
-	ble,pn	%icc, .LL1
+	ble,pn	%icc, .LL10
+	nop
 	mov	1024, %l3
 	add	%fp, -1064, %i5
 	add	%fp, -1072, %l7
@@ -59,8 +58,8 @@
 	cmp	%l4, 0
 	bg,pt	%icc, .LL4
 	add	%l5, 4, %l5
-.LL1:
+.LL10:
 	return	%i7+8
-	nop
+	 nop
 	.size	sdbm__splpage, .-sdbm__splpage
 	.ident	"GCC: (GNU) 3.5.0 20040620 (experimental)"

It appears that the compiler fails to realize that the value of the register
doesn't matter on the non-fallthru edge pointing to the return.
Comment 1 Eric Botcazou 2004-07-07 13:44:21 UTC
Investigating.
Comment 2 Eric Botcazou 2004-07-11 12:43:39 UTC
Testing various patches against the reorg pass.
Comment 3 Giovanni Bajo 2004-07-11 23:16:06 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg01167.html
Comment 4 CVS Commits 2004-07-17 18:12:41 UTC
Subject: Bug 16294

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2004-07-17 18:12:38

Modified files:
	gcc            : ChangeLog resource.c 

Log message:
	PR rtl-optimization/16294
	* resource.c (return_insn_p): New predicate.
	(mark_target_live_regs): Use it.  Special-case return insns.
	(init_resource_info): Use it.  Don't scan the epilogue past
	a return.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4586&r2=2.4587
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/resource.c.diff?cvsroot=gcc&r1=1.71&r2=1.72

Comment 5 Eric Botcazou 2004-07-17 18:15:18 UTC
Patch commited (with a slight tweak).