public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: David S. Miller <davem@jenolan.rutgers.edu>
To: egcs@cygnus.com
Subject: Re: Reload patch to improve 386 code
Date: Mon, 18 Aug 1997 18:55:26 -0000	[thread overview]
Message-ID: <199708181855.OAA03711@jenolan.rutgers.edu> (raw)
In-Reply-To: Reload patch to improve 386 code

   Date: Mon, 18 Aug 1997 11:17:38 -0400 (EDT)
   From: meissner@cygnus.com

   I think it is an horrible kludge that reload is run as a pass after
   global-alloc, and that it forces reload registers not to be used
   for any other purpose (which is murder on the x86 with each
   register being special purpose in some way).

Before this leaves my head, I wanted to point something out which
you've reminded me of.  When the scheduler (this applies to both the
original and Haifa versions equally) becomes aggressive, it produces a
large number of reloads in certain situations.  Reloads which would
not have happened if scheduling did not take place.  This happens
especially if register pressure is high already.  I noticed this
particularly on RISC platforms, seems in this case the more registers
available the worse things became when the register usage was
saturated.

Another thing I saw gcc do for a register constrained function was the
following.  Consider a function which references a lot of global data
structures, which it iterates over as a 3 level indirected table.  It
also references 2 or 3 global pieces of data in a few distinct places
within the iteration (the specific example is specifically the
function mm/memory.c:copy_page_range() on sparc64 in the Linux kernel)
A rough outline is:

inline copy_one_pte() {
	if(pte_none(pte))
		return;
	if(!pte_present(pte)) {
		duplicate_swap_information();
		return;
	}
	copy_pte_info_and_maybe_cow();
}

inline copy_pte_range() {
	for_all_ptes_in_this_pmd()
		copy_one_pte();
}

inline copy_pmd_range() {
	for_all_pmds_in_this_pgd()
		copy_pte_range();
}

copy_page_range() {
	for_all_pgds_in_this_range()
		copy_pmd_range();
}

Now, I have two global physical addresses I use for "null" page
tables, which is what newly allocated page tables point to before they
are set to point to anything specific.  There is heavy inlining done
here and on sparc64 it can end up allocating 300 or 400 bytes of stack
space.  Anyways, back to my main point, the two physical addresses for
the null page table pages live in two global variables
"null_pte_table" and "null_pmd_table".  The progression in the
produced code wrt. these two variables is:

copy_page_range:

	sethi	%hi(null_pte_table), %r
	or	%r, %lo(null_pte_table), %r
	stx	%r, [%sp + slot1]
	sethi	%hi(null_pmd_table), %r
	or	%r, %lo(null_pmd_table), %r
	stx	%r, [%sp + slot2]

...

main_loop:
	...
	/* we need to use null_pmd_table's value here */
	ldx	[%sp + slot1], %r
	ldx	[%r], %r2
	use it
	stx	%r2, [%sp + slot3]
	...
	/* we need to use null_pte_table's value here */
	ldx	[%sp + slot2], %r
	ldx	[%r], %r2
	use it
	stx	%r2, [%sp + %slot4]	
	...
	/* need again to use null_pmd_table's value */
	ldx	[%sp + slot3], %r
	use it
	...
	/* need again to use null_pte_table's value */
	ldx	[%sp + slot4], %r
	use it
	...
	b	main_loop

Anyways you get the picture, I see often these "gradual" reloads,
where final values are computed partially, given a stack slot for
reloading purposes, and then loaded back and computed further, then
given yet another stack slot.  On RISC systems this can account for a
significant portion of the stack slots taken up for a given function.

   Now, given it is a rather critical piece of the compiler, it may
   take months if not years to get it better than it currently is.

Well, perhaps it would be prudent to have people start now in the
background to get this work going?

Later,
David "Sparc" Miller
davem@caip.rutgers.edu

WARNING: multiple messages have this Message-ID
From: Jeffrey A Law <law@hurl.cygnus.com>
To: egcs@cygnus.com
Subject: Re: Reload patch to improve 386 code
Date: Mon, 18 Aug 1997 19:09:07 -0000	[thread overview]
Message-ID: <199708181855.OAA03711@jenolan.rutgers.edu> (raw)
Message-ID: <19970818190907.ZxKByeA8-bxzcPTcdTtR67R5e9h6Pwl7RykS_aFRR68@z> (raw)
In-Reply-To: Reload patch to improve 386 code

  In message <199708181855.OAA03711@jenolan.rutgers.edu>you write:
  > Before this leaves my head, I wanted to point something out which
  > you've reminded me of.  When the scheduler (this applies to both the
  > original and Haifa versions equally) becomes aggressive, it produces a
  > large number of reloads in certain situations.  Reloads which would
  > not have happened if scheduling did not take place.  This happens
  > especially if register pressure is high already.  I noticed this
  > particularly on RISC platforms, seems in this case the more registers
  > available the worse things became when the register usage was
  > saturated.
Yup.  Absolutely.  This is a known issue with schedulers in general;
you can see this in action if you look at fpppp in spec.

The haifa scheduler has some code to "prefer" schedules which don't
lengthen register lifetimes, but I don't know how effective it really
is.  The normal scheduler has some code to do this too, but it's less
effective than haifa.

However, I've done experiments and the more I make the scheduler
try to reduce register lifetimes, the worse _overall_ performance I
see.

It almost makes me think such code should be dependent on the number
of registers actually in the code -- ie once the ratio of pseudos
to hard registers hits some magic point, the code to shorten lifetimes
kicks in and tries to keep the scheduler from extending register
lifetimes.

jeff

             reply	other threads:[~1997-08-18 18:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-18 18:55 David S. Miller [this message]
1997-08-18 19:09 ` Jeffrey A Law
     [not found] <Pine.SOL.3.90.970819095143.291G-100000@starsky.informatik.rwth-aachen.de>
1998-09-04  5:03 ` Jeffrey A Law
1998-09-04  5:05   ` Bernd Schmidt
1998-09-04 22:36     ` Joern Rennecke
1998-09-05  4:45     ` Jeffrey A Law
1998-09-05 15:49       ` Joern Rennecke
1998-09-05 15:44         ` Jeffrey A Law
1998-09-06  1:09           ` Mark Mitchell
1998-09-06  1:09             ` Jeffrey A Law
1998-09-07  9:48       ` Bernd Schmidt
1998-09-07 19:09         ` Joern Rennecke
1998-09-07 18:26           ` Jeffrey A Law
1998-09-07 19:09         ` Jeffrey A Law
1998-09-04 21:38   ` Joern Rennecke
1998-09-04 21:38     ` Jeffrey A Law
  -- strict thread matches above, loose matches on Subject: below --
1997-08-21 16:51 Problems on PowerPC David Edelsohn
1997-08-21 17:37 ` Reload patch to improve 386 code Bernd Schmidt
1997-08-21 16:51 Joern Rennecke
1997-08-21 15:20 egcs repository Joel Sherrill
1997-08-21 15:47 ` Reload patch to improve 386 code Bernd Schmidt
1997-08-19 19:00 Joern Rennecke
1997-08-19  8:50 Jakub Jelinek
1997-08-19  7:36 egcs: A new compiler project to merge the existing GCC forks (fwd) Robert Wilhelm
1997-08-19  8:08 ` Reload patch to improve 386 code Bernd Schmidt
1997-08-19  8:08 ` Bernd Schmidt
1997-08-19  8:08 ` Jeffrey A Law
1997-08-18 20:47 Mike Meissner
1997-08-18 20:46 Joern Rennecke
1997-08-18 15:36 Toon Moene
1997-08-18 15:11 meissner
1997-08-18 14:53 meissner
1997-08-18 14:53 Monday morning Philippe Laliberte
1997-08-18 14:54 ` Reload patch to improve 386 code Jeffrey A Law
1997-08-18 14:53 Toon Moene
1997-08-18  8:13 Test result for 970814 on native sparc-sun-solaris2.5.1 Klaus Kaempf
1997-08-18  8:22 ` Reload patch to improve 386 code Bernd Schmidt
1997-08-18 10:11 ` Bernd Schmidt

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=199708181855.OAA03711@jenolan.rutgers.edu \
    --to=davem@jenolan.rutgers.edu \
    --cc=egcs@cygnus.com \
    /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).