[PATCH] Fix PR rtl-optimization/16294

Eric Botcazou ebotcazou@libertysurf.fr
Sun Jul 11 23:49:00 GMT 2004


Hi,

This is the code quality regression introduced my RTL prologue/epilogue patch 
on SPARC, which shows up in about a dozen of testcases of the C testsuite 
gcc.c-torture/compile at -O2.  It's typically:

@@ -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

that is, the slot of branches targetting the return is not filled anymore.


The problem lies in resource.c and is twofold:
- mark_target_live_regs pessimizes way too much when computing the liveness 
information for the return (it may end up scanning forwards from the 
beginning of the function!).  The proposed fix is basically to reuse the 
liveness information computed for the end of the function.
- the liveness information computed for the end of the function is awful when 
the epilogue is emitted in the middle of the function: the function is 
scanned til the end!

The patch cures all code quality regressions in the gcc.c-torture/compile 
testsuite at -O2 except one (a corner case with ill-formed code).  I think 
an additional win could be to apply the trick to every insn in the epilogue, 
scanning backwards from the return.  I'll be experimenting this.

Bootstrapped/regtested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.8.  
OK for mainline?


2004-07-11  Eric Botcazou  <ebotcazou@libertysurf.fr>

	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.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr16294-2.diff
Type: text/x-diff
Size: 1624 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040711/559388fe/attachment.bin>


More information about the Gcc-patches mailing list