public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 14/15] alpha: Split out alpha_cost_set_const
Date: Wed, 12 Aug 2015 01:12:00 -0000	[thread overview]
Message-ID: <1439341904-9345-15-git-send-email-rth@redhat.com> (raw)
In-Reply-To: <1439341904-9345-1-git-send-email-rth@redhat.com>

Now that it's easy, avoid the "no_output" parameter
to alpha_emit_set_const.
---
	* config/alpha/alpha.c (alpha_cost_set_const): New.
	(alpha_legitimate_constant_p): Use it
	(alpha_emit_set_const): Remove no_output param.
	(alpha_split_const_mov): Update call.
	(alpha_expand_epilogue): Likewise.
---
 gcc/config/alpha/alpha.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 6933601..cc25250 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -1998,6 +1998,18 @@ genimm_alpha::generate (rtx dest, machine_mode mode) const
 
 } // anon namespace
 
+/* Return the cost of outputting the constant C in MODE.  */
+
+static int
+alpha_cost_set_const (machine_mode mode, HOST_WIDE_INT c)
+{
+  if (mode == V8QImode || mode == V4HImode || mode == V2SImode)
+    mode = DImode;
+
+  genimm_alpha data = genimm_hash<genimm_alpha>::hash (c, mode);
+  return data.cost;
+}
+
 /* Try to output insns to set TARGET equal to the constant C if it can be
    done in less than N insns.  Do all computations in MODE.  Returns the place
    where the output has been placed if it can be done and the insns have been
@@ -2006,7 +2018,7 @@ genimm_alpha::generate (rtx dest, machine_mode mode) const
 
 static rtx
 alpha_emit_set_const (rtx target, machine_mode origmode,
-		      HOST_WIDE_INT c, int n, bool no_output)
+		      HOST_WIDE_INT c, int n)
 {
   machine_mode mode = origmode;
   if (mode == V8QImode || mode == V4HImode || mode == V2SImode)
@@ -2016,10 +2028,6 @@ alpha_emit_set_const (rtx target, machine_mode origmode,
   if (data.cost > n)
     return NULL;
 
-  /* If we're not emitting output, we only need return a nonnull value.  */
-  if (no_output)
-    return pc_rtx;
-
   if (origmode == mode)
     data.generate (target, mode);
   else
@@ -2132,7 +2140,7 @@ alpha_legitimate_constant_p (machine_mode mode, rtx x)
       mode = DImode;
       gcc_assert (CONST_WIDE_INT_NUNITS (x) == 2);
       i0 = CONST_WIDE_INT_ELT (x, 1);
-      if (alpha_emit_set_const (NULL_RTX, mode, i0, 3, true) == NULL)
+      if (alpha_cost_set_const (mode, i0) > 3)
 	return false;
       i0 = CONST_WIDE_INT_ELT (x, 0);
       goto do_integer;
@@ -2156,7 +2164,7 @@ alpha_legitimate_constant_p (machine_mode mode, rtx x)
 	return true;
       i0 = alpha_extract_integer (x);
     do_integer:
-      return alpha_emit_set_const (NULL_RTX, mode, i0, 3, true) != NULL;
+      return alpha_cost_set_const (mode, i0) <= 3;
 
     default:
       return false;
@@ -2174,7 +2182,7 @@ alpha_split_const_mov (machine_mode mode, rtx *operands)
 
   i0 = alpha_extract_integer (operands[1]);
 
-  temp = alpha_emit_set_const (operands[0], mode, i0, 3, false);
+  temp = alpha_emit_set_const (operands[0], mode, i0, 3);
 
   if (!temp && TARGET_BUILD_CONSTANTS)
     temp = alpha_emit_set_long_const (operands[0], i0);
@@ -8212,7 +8220,7 @@ alpha_expand_epilogue (void)
       else
 	{
 	  rtx tmp = gen_rtx_REG (DImode, 23);
-	  sp_adj2 = alpha_emit_set_const (tmp, DImode, frame_size, 3, false);
+	  sp_adj2 = alpha_emit_set_const (tmp, DImode, frame_size, 3);
 	  if (!sp_adj2)
 	    {
 	      /* We can't drop new things to memory this late, afaik,
-- 
2.4.3

  parent reply	other threads:[~2015-08-12  1:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12  1:11 [PATCH ppc64,aarch64,alpha 00/15] Improve backend constant generation Richard Henderson
2015-08-12  1:11 ` [PATCH 05/15] rs6000: Move constant via mask into build_set_const_data Richard Henderson
2015-08-12  1:11 ` [PATCH 01/15] rs6000: Split out rs6000_is_valid_and_mask_wide Richard Henderson
2015-08-12 13:24   ` Segher Boessenkool
2015-08-12 15:50     ` Richard Henderson
2015-08-13  2:29       ` Segher Boessenkool
2015-08-12  1:12 ` [PATCH 02/15] rs6000: Make num_insns_constant_wide static Richard Henderson
2015-08-12  1:12 ` [PATCH 04/15] rs6000: Implement set_const_data infrastructure Richard Henderson
2015-08-12 13:53   ` Segher Boessenkool
2015-08-12  1:12 ` [PATCH 09/15] rs6000: Use xoris in constant construction Richard Henderson
2015-08-12  1:12 ` [PATCH 13/15] alpha: Use hashing infrastructure for generating constants Richard Henderson
2015-08-12  1:12 ` [PATCH 15/15] alpha: Remove alpha_emit_set_long_const Richard Henderson
2015-08-12  1:12 ` [PATCH 12/15] aarch64: Test for duplicated 32-bit halves Richard Henderson
2015-08-12  1:12 ` [PATCH 10/15] rs6000: Use rotldi in constant generation Richard Henderson
2015-08-12  1:12 ` [PATCH 07/15] rs6000: Generalize left shift " Richard Henderson
2015-08-12  1:12 ` Richard Henderson [this message]
2015-08-12  1:12 ` [PATCH 03/15] rs6000: Tidy num_insns_constant vs CONST_DOUBLE Richard Henderson
2015-08-12  1:12 ` [PATCH 08/15] rs6000: Generalize masking in constant generation Richard Henderson
2015-08-12  1:12 ` [PATCH 11/15] aarch64: Use hashing infrastructure for generating constants Richard Henderson
2015-08-12  1:12 ` [PATCH 06/15] rs6000: Use rldiwi in constant construction Richard Henderson
2015-08-12 14:02   ` Segher Boessenkool
2015-08-12 15:55     ` Richard Henderson
2015-08-13  2:43       ` Segher Boessenkool
2015-08-13 19:01         ` Mike Stump
2015-08-13 20:30           ` Joseph Myers
2015-08-12  8:32 ` [PATCH ppc64,aarch64,alpha 00/15] Improve backend constant generation Segher Boessenkool
2015-08-12 15:32   ` Richard Henderson
2015-08-13  3:07     ` Segher Boessenkool
2015-08-13  5:36       ` Segher Boessenkool
2015-08-13  3:10   ` Segher Boessenkool
2015-08-13 11:32     ` David Edelsohn
2015-08-12  8:32 ` Richard Earnshaw
2015-08-12  8:43   ` Richard Earnshaw
2015-08-12  9:02     ` Richard Earnshaw
2015-08-12 15:45   ` Richard Henderson

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=1439341904-9345-15-git-send-email-rth@redhat.com \
    --to=rth@redhat.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).