public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Peter Bergner <bergner@vnet.ibm.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] PR35371 GCSE loses track of REG_POINTER attribute
Date: Mon, 25 Feb 2008 22:30:00 -0000	[thread overview]
Message-ID: <20080225222624.GA26857@vervain.rchland.ibm.com> (raw)

While tracking down an unrelated performance problem, I noticed that
for the following simple loop, we generate indexed form stores and that
we get the ordering of the operands wrong which causes a slowdown on
POWER6 (see PR28690 for more details).  The culprit here is GCSE.
When GCSE creates a pseudo reg to copy a reaching expression into,
it fails to copy the REG_POINTER attribute over to the new pseudo.
This new pseudo is then analyzed by the new code we added to PR28690
and since there is no REG_POINTER attribute, we fail to swap the operands
into the correct order.  This patch makes sure we inherit the REG_POINTER
attribute.

Is this patch ok for mainline once bootstrap and regression testing have
completed?  Given PR28690 was a 4.3 regression, is this ok for 4.3.1 once
that is open for fixes?

Peter

	PR rtl-optimization/35371
        * gcse.c (gen_reaching_reg_rtx): New function.
	(pre_delete): Use it.
	(hoist_code): Likewise.
	(build_store_vectors): Likewise.
	(delete_store): Likewise.

Index: gcse.c
===================================================================
--- gcse.c	(revision 132568)
+++ gcse.c	(working copy)
@@ -818,6 +818,24 @@ gcse_main (rtx f ATTRIBUTE_UNUSED)
 \f
 /* Misc. utilities.  */
 
+/* Create a pseudo reg to copy the result of a reaching expression into.
+   Be careful to inherit the REG_POINTER attribute.  */
+
+static rtx
+gen_reaching_reg_rtx (rtx x)
+{
+  rtx reg;
+
+  gcc_assert (REG_P (x));
+
+  reg = gen_reg_rtx (GET_MODE (x));
+
+  if (REG_POINTER (x))
+    mark_reg_pointer (reg, REGNO_POINTER_ALIGN (REGNO (x)));
+
+  return reg;
+}
+
 /* Nonzero for each mode that supports (set (reg) (reg)).
    This is trivially true for integer and floating point values.
    It may or may not be true for condition codes.  */
@@ -4456,8 +4474,7 @@ pre_delete (void)
 		   expressions into.  Get the mode for the new pseudo from
 		   the mode of the original destination pseudo.  */
 		if (expr->reaching_reg == NULL)
-		  expr->reaching_reg
-		    = gen_reg_rtx (GET_MODE (SET_DEST (set)));
+		  expr->reaching_reg = gen_reaching_reg_rtx (SET_DEST (set));
 
 		gcse_emit_move_after (expr->reaching_reg, SET_DEST (set), insn);
 		delete_insn (insn);
@@ -4981,7 +4998,7 @@ hoist_code (void)
 			 from the mode of the original destination pseudo.  */
 		      if (expr->reaching_reg == NULL)
 			expr->reaching_reg
-			  = gen_reg_rtx (GET_MODE (SET_DEST (set)));
+			  = gen_reaching_reg_rtx (SET_DEST (set));
 
 		      gcse_emit_move_after (expr->reaching_reg, SET_DEST (set), insn);
 		      delete_insn (insn);
@@ -6114,7 +6131,7 @@ build_store_vectors (void)
 	     are any side effects.  */
 	  if (TEST_BIT (ae_gen[bb->index], ptr->index))
 	    {
-	      rtx r = gen_reg_rtx (GET_MODE (ptr->pattern));
+	      rtx r = gen_reaching_reg_rtx (ptr->pattern);
 	      if (dump_file)
 		fprintf (dump_file, "Removing redundant store:\n");
 	      replace_store_insn (r, XEXP (st, 0), bb, ptr);
@@ -6437,7 +6454,7 @@ delete_store (struct ls_expr * expr, bas
   rtx reg, i, del;
 
   if (expr->reaching_reg == NULL_RTX)
-    expr->reaching_reg = gen_reg_rtx (GET_MODE (expr->pattern));
+    expr->reaching_reg = gen_reaching_reg_rtx (expr->pattern);
 
   reg = expr->reaching_reg;
 

             reply	other threads:[~2008-02-25 22:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25 22:30 Peter Bergner [this message]
2008-02-25 23:13 ` Peter Bergner
2008-02-26  5:25 ` [PATCH,updated] " Peter Bergner
2008-02-26  5:49   ` [PATCH,withdrawn] " Peter Bergner
2008-02-26 18:00 ` [PATCH] " Richard Sandiford
2008-02-26 19:04   ` Peter Bergner
2008-02-26 19:45     ` Richard Sandiford
2008-02-26 20:06     ` Jeff Law
2008-02-29  1:32       ` Peter Bergner
2008-03-03 19:17         ` Jeff Law
2008-03-03 19:42           ` Peter Bergner
2008-03-03 20:55             ` Jeff Law
2008-03-10 15:32         ` [PING H.J. Lu] " Peter Bergner
2008-03-10 16:22           ` H.J. Lu
2008-03-12 14:48           ` H.J. Lu
2008-03-17 14:32             ` H.J. Lu

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=20080225222624.GA26857@vervain.rchland.ibm.com \
    --to=bergner@vnet.ibm.com \
    --cc=gcc-patches@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).