public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Schmidt <bernds@codesourcery.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Jeff Law <law@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>,
	 Jakub Jelinek <jakub@redhat.com>,
	Alexandre Oliva <aoliva@redhat.com>
Subject: Re: New optimization for reload_combine
Date: Tue, 20 Jul 2010 15:34:00 -0000	[thread overview]
Message-ID: <4C45C1DF.2070308@codesourcery.com> (raw)
In-Reply-To: <4C458C71.7070809@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

On 07/20/2010 01:45 PM, Bernd Schmidt wrote:
> It's still producing different code for -g vs. no-debug on powerpc.  It
> turns out that we only store a limited amount of uses for a reg, and
> somehow the powerpc compiler produces a huge amount of debug_insns,
> which fill the buffer and prevent us from doing the optimization on real
> insns.
> 
> Not sure yet how to fix it, probably by not tracking DEBUG_INSNs at all
> and letting them get out of date.

Here's a fix, which I've committed.  Bootstrapped and regression tested
on i686-linux, and also verified that I can no longer reproduce output
differences with a powerpc cross compiler.  It even tries to fix up the
debug insns in the range of insns we're changing so that should be OK too.


Bernd

[-- Attachment #2: more-debug-insns.diff --]
[-- Type: text/plain, Size: 4316 bytes --]

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 162341)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2010-07-20  Bernd Schmidt  <bernds@codesourcery.com>
+
+	* postreload.c (fixup_debug_insns): Remove arg REGNO.  New args
+	FROM and TO.  All callers changed.  Don't look for tracked uses,
+	just scan the RTL for DEBUG_INSNs and substitute.
+	(reload_combine_recognize_pattern): Call fixup_debug_insns.
+	(reload_combine): Ignore DEBUG_INSNs.
+
 2010-07-20  Jakub Jelinek  <jakub@redhat.com>
 
 	* var-tracking.c (vt_expand_loc, vt_expand_loc_dummy): Bump maximum
Index: postreload.c
===================================================================
--- postreload.c	(revision 162301)
+++ postreload.c	(working copy)
@@ -848,41 +848,26 @@ reload_combine_closest_single_use (unsig
   return retval;
 }
 
-/* After we've moved an add insn, fix up any debug insns that occur between
-   the old location of the add and the new location.  REGNO is the destination
-   register of the add insn; REG is the corresponding RTX.  REPLACEMENT is
-   the SET_SRC of the add.  MIN_RUID specifies the ruid of the insn after
-   which we've placed the add, we ignore any debug insns after it.  */
+/* After we've moved an add insn, fix up any debug insns that occur
+   between the old location of the add and the new location.  REG is
+   the destination register of the add insn; REPLACEMENT is the
+   SET_SRC of the add.  FROM and TO specify the range in which we
+   should make this change on debug insns.  */
 
 static void
-fixup_debug_insns (unsigned regno, rtx reg, rtx replacement, int min_ruid)
+fixup_debug_insns (rtx reg, rtx replacement, rtx from, rtx to)
 {
-  struct reg_use *use;
-  int from = reload_combine_ruid;
-  for (;;)
+  rtx insn;
+  for (insn = from; insn != to; insn = NEXT_INSN (insn))
     {
       rtx t;
-      rtx use_insn = NULL_RTX;
-      if (from < min_ruid)
-	break;
-      use = reload_combine_closest_single_use (regno, from);
-      if (use)
-	{
-	  from = use->ruid;
-	  use_insn = use->insn;
-	}
-      else
-	break;
-      
-      if (NONDEBUG_INSN_P (use->insn))
+
+      if (!DEBUG_INSN_P (insn))
 	continue;
-      t = INSN_VAR_LOCATION_LOC (use_insn);
+      
+      t = INSN_VAR_LOCATION_LOC (insn);
       t = simplify_replace_rtx (t, reg, copy_rtx (replacement));
-      validate_change (use->insn,
-		       &INSN_VAR_LOCATION_LOC (use->insn), t, 0);
-      reload_combine_purge_insn_uses (use_insn);
-      reload_combine_note_use (&PATTERN (use_insn), use_insn,
-			       use->ruid, NULL_RTX);
+      validate_change (insn, &INSN_VAR_LOCATION_LOC (insn), t, 0);
     }
 }
 
@@ -1063,8 +1048,8 @@ reload_combine_recognize_const_pattern (
     /* Process the add normally.  */
     return false;
 
-  fixup_debug_insns (regno, reg, src, add_moved_after_ruid);
-  
+  fixup_debug_insns (reg, src, insn, add_moved_after_insn);
+
   reorder_insns (insn, insn, add_moved_after_insn);
   reload_combine_purge_reg_uses_after_ruid (regno, add_moved_after_ruid);
   reload_combine_split_ruids (add_moved_after_ruid - 1);
@@ -1191,15 +1176,21 @@ reload_combine_recognize_pattern (rtx in
 
 	  if (apply_change_group ())
 	    {
+	      struct reg_use *lowest_ruid = NULL;
+
 	      /* For every new use of REG_SUM, we have to record the use
 		 of BASE therein, i.e. operand 1.  */
 	      for (i = reg_state[regno].use_index;
 		   i < RELOAD_COMBINE_MAX_USES; i++)
-		reload_combine_note_use
-		  (&XEXP (*reg_state[regno].reg_use[i].usep, 1),
-		   reg_state[regno].reg_use[i].insn,
-		   reg_state[regno].reg_use[i].ruid,
-		   reg_state[regno].reg_use[i].containing_mem);
+		{
+		  struct reg_use *use = reg_state[regno].reg_use + i;
+		  reload_combine_note_use (&XEXP (*use->usep, 1), use->insn,
+					   use->ruid, use->containing_mem);
+		  if (lowest_ruid == NULL || use->ruid < lowest_ruid->ruid)
+		    lowest_ruid = use;
+		}
+
+	      fixup_debug_insns (reg, reg_sum, insn, lowest_ruid->insn);
 
 	      /* Delete the reg-reg addition.  */
 	      delete_insn (insn);
@@ -1313,7 +1304,7 @@ reload_combine (void)
 	  if (! fixed_regs[r])
 	      reg_state[r].use_index = RELOAD_COMBINE_MAX_USES;
 
-      if (! INSN_P (insn))
+      if (! NONDEBUG_INSN_P (insn))
 	continue;
 
       reload_combine_ruid++;

  parent reply	other threads:[~2010-07-20 15:34 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16 10:35 Bernd Schmidt
2010-07-16 18:32 ` Jeff Law
2010-07-16 23:50   ` Bernd Schmidt
2010-07-17  2:38     ` H.J. Lu
2010-07-17 14:25       ` Bernd Schmidt
2010-07-17 15:03         ` H.J. Lu
2010-07-17 15:10           ` IainS
2010-07-17 16:00           ` Bernd Schmidt
2010-07-17 16:15             ` H.J. Lu
2010-07-17 17:18               ` Bernd Schmidt
2010-07-17 17:27                 ` H.J. Lu
2010-07-17 17:29                 ` IainS
2010-07-18 18:15             ` H.J. Lu
2010-07-19 10:01           ` Bernd Schmidt
2010-07-19 13:27             ` H.J. Lu
2010-07-20 11:46             ` Bernd Schmidt
2010-07-20 15:33               ` Jeff Law
2010-07-20 15:34               ` Bernd Schmidt [this message]
2010-07-20 15:40                 ` Jakub Jelinek
2010-07-19 15:41         ` x86_64 varargs setup jump table Richard Henderson
2010-07-19 15:56           ` H.J. Lu
2010-07-19 20:57             ` H.J. Lu
2010-07-19 21:14               ` Richard Henderson
2010-07-20 16:32                 ` Richard Henderson
2010-07-20 23:05                   ` Richard Henderson
2010-07-20 23:21                     ` Sebastian Pop
2010-07-22 13:52                     ` H.J. Lu
2010-07-22 18:03                       ` Sebastian Pop
2010-07-22 18:15                         ` Richard Henderson
2010-07-22 18:17                           ` Richard Henderson
2010-07-22 18:20                             ` Sebastian Pop
2010-07-21 23:15                   ` H.J. Lu
2010-07-22 21:53                     ` Fix target/45027 [was: x86_64 varargs setup jump table] Richard Henderson
2010-07-23  9:07                       ` Richard Guenther
2010-07-19 16:09           ` x86_64 varargs setup jump table Andi Kleen
2010-07-19 16:16             ` H.J. Lu
2010-07-19 16:26               ` Andi Kleen
2010-07-19 16:23           ` Jan Hubicka
2010-07-19 16:19         ` New optimization for reload_combine Jeff Law
2010-11-04  4:30       ` H.J. Lu
2010-07-16 19:45 ` Paolo Bonzini
2010-07-16 19:55   ` Bernd Schmidt
2010-07-16 20:24     ` Paolo Bonzini
2010-07-19 16:11   ` Mark Mitchell
2010-07-19 16:13     ` Jeff Law
2010-07-19 16:31     ` Paolo Bonzini
2010-07-26 10:13 ` IainS
2010-07-26 10:46   ` Bernd Schmidt
2010-07-27  0:53   ` 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=4C45C1DF.2070308@codesourcery.com \
    --to=bernds@codesourcery.com \
    --cc=aoliva@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=jakub@redhat.com \
    --cc=law@redhat.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).