diff mbox

[GCC8,16/33] Move multiplier_allowed_in_address_p to tree-ssa-address

Message ID VI1PR0802MB2176C0AC3DCD6042C83A83E5E7190@VI1PR0802MB2176.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng April 18, 2017, 10:45 a.m. UTC
Hi,
Now function multiplier_allowed_in_address_p is no longer referred in ivopts,
so move to the only file using it and make it static.

Thanks,
bin
2017-04-11  Bin Cheng  <bin.cheng@arm.com>

	* tree-ssa-loop-ivopts.c (multiplier_allowed_in_address_p): Move
	from ...
	* tree-ssa-address.c (multiplier_allowed_in_address_p): ... to here
	as local function.  Include necessary header files.
	* tree-ssa-loop-ivopts.h (multiplier_allowed_in_address_p): Delete.
From d55aefd90a2443eb97a3de5ed411df77cf66d46a Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Wed, 1 Mar 2017 14:28:55 +0000
Subject: [PATCH 16/33] multiplier_allowed_in_address_p-20170220.txt

---
 gcc/tree-ssa-address.c     | 58 ++++++++++++++++++++++++++++++++++++++++++++++
 gcc/tree-ssa-loop-ivopts.c | 57 ---------------------------------------------
 gcc/tree-ssa-loop-ivopts.h |  2 --
 3 files changed, 58 insertions(+), 59 deletions(-)

Comments

Richard Biener April 26, 2017, 12:58 p.m. UTC | #1
On Tue, Apr 18, 2017 at 12:45 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> Now function multiplier_allowed_in_address_p is no longer referred in ivopts,
> so move to the only file using it and make it static.

Ok.

Richard.

> Thanks,
> bin
> 2017-04-11  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-ssa-loop-ivopts.c (multiplier_allowed_in_address_p): Move
>         from ...
>         * tree-ssa-address.c (multiplier_allowed_in_address_p): ... to here
>         as local function.  Include necessary header files.
>         * tree-ssa-loop-ivopts.h (multiplier_allowed_in_address_p): Delete.
diff mbox

Patch

diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c
index e35d323..8aefed6 100644
--- a/gcc/tree-ssa-address.c
+++ b/gcc/tree-ssa-address.c
@@ -28,11 +28,13 @@  along with GCC; see the file COPYING3.  If not see
 #include "rtl.h"
 #include "tree.h"
 #include "gimple.h"
+#include "memmodel.h"
 #include "stringpool.h"
 #include "tree-vrp.h"
 #include "tree-ssanames.h"
 #include "expmed.h"
 #include "insn-config.h"
+#include "emit-rtl.h"
 #include "recog.h"
 #include "tree-pretty-print.h"
 #include "fold-const.h"
@@ -537,6 +539,62 @@  add_to_parts (struct mem_address *parts, tree elt)
 			       parts->base, elt);
 }
 
+/* Returns true if multiplying by RATIO is allowed in an address.  Test the
+   validity for a memory reference accessing memory of mode MODE in address
+   space AS.  */
+
+static bool
+multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, machine_mode mode,
+				 addr_space_t as)
+{
+#define MAX_RATIO 128
+  unsigned int data_index = (int) as * MAX_MACHINE_MODE + (int) mode;
+  static vec<sbitmap> valid_mult_list;
+  sbitmap valid_mult;
+
+  if (data_index >= valid_mult_list.length ())
+    valid_mult_list.safe_grow_cleared (data_index + 1);
+
+  valid_mult = valid_mult_list[data_index];
+  if (!valid_mult)
+    {
+      machine_mode address_mode = targetm.addr_space.address_mode (as);
+      rtx reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1);
+      rtx reg2 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2);
+      rtx addr, scaled;
+      HOST_WIDE_INT i;
+
+      valid_mult = sbitmap_alloc (2 * MAX_RATIO + 1);
+      bitmap_clear (valid_mult);
+      scaled = gen_rtx_fmt_ee (MULT, address_mode, reg1, NULL_RTX);
+      addr = gen_rtx_fmt_ee (PLUS, address_mode, scaled, reg2);
+      for (i = -MAX_RATIO; i <= MAX_RATIO; i++)
+	{
+	  XEXP (scaled, 1) = gen_int_mode (i, address_mode);
+	  if (memory_address_addr_space_p (mode, addr, as)
+	      || memory_address_addr_space_p (mode, scaled, as))
+	    bitmap_set_bit (valid_mult, i + MAX_RATIO);
+	}
+
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	{
+	  fprintf (dump_file, "  allowed multipliers:");
+	  for (i = -MAX_RATIO; i <= MAX_RATIO; i++)
+	    if (bitmap_bit_p (valid_mult, i + MAX_RATIO))
+	      fprintf (dump_file, " %d", (int) i);
+	  fprintf (dump_file, "\n");
+	  fprintf (dump_file, "\n");
+	}
+
+      valid_mult_list[data_index] = valid_mult;
+    }
+
+  if (ratio > MAX_RATIO || ratio < -MAX_RATIO)
+    return false;
+
+  return bitmap_bit_p (valid_mult, ratio + MAX_RATIO);
+}
+
 /* Finds the most expensive multiplication in ADDR that can be
    expressed in an addressing mode and move the corresponding
    element(s) to PARTS.  */
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 4948a47..c3e9bce 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -3905,63 +3905,6 @@  adjust_setup_cost (struct ivopts_data *data, unsigned cost,
     return cost;
 }
 
-/* Returns true if multiplying by RATIO is allowed in an address.  Test the
-   validity for a memory reference accessing memory of mode MODE in
-   address space AS.  */
-
-
-bool
-multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, machine_mode mode,
-				 addr_space_t as)
-{
-#define MAX_RATIO 128
-  unsigned int data_index = (int) as * MAX_MACHINE_MODE + (int) mode;
-  static vec<sbitmap> valid_mult_list;
-  sbitmap valid_mult;
-
-  if (data_index >= valid_mult_list.length ())
-    valid_mult_list.safe_grow_cleared (data_index + 1);
-
-  valid_mult = valid_mult_list[data_index];
-  if (!valid_mult)
-    {
-      machine_mode address_mode = targetm.addr_space.address_mode (as);
-      rtx reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1);
-      rtx reg2 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2);
-      rtx addr, scaled;
-      HOST_WIDE_INT i;
-
-      valid_mult = sbitmap_alloc (2 * MAX_RATIO + 1);
-      bitmap_clear (valid_mult);
-      scaled = gen_rtx_fmt_ee (MULT, address_mode, reg1, NULL_RTX);
-      addr = gen_rtx_fmt_ee (PLUS, address_mode, scaled, reg2);
-      for (i = -MAX_RATIO; i <= MAX_RATIO; i++)
-	{
-	  XEXP (scaled, 1) = gen_int_mode (i, address_mode);
-	  if (memory_address_addr_space_p (mode, addr, as)
-	      || memory_address_addr_space_p (mode, scaled, as))
-	    bitmap_set_bit (valid_mult, i + MAX_RATIO);
-	}
-
-      if (dump_file && (dump_flags & TDF_DETAILS))
-	{
-	  fprintf (dump_file, "  allowed multipliers:");
-	  for (i = -MAX_RATIO; i <= MAX_RATIO; i++)
-	    if (bitmap_bit_p (valid_mult, i + MAX_RATIO))
-	      fprintf (dump_file, " %d", (int) i);
-	  fprintf (dump_file, "\n");
-	  fprintf (dump_file, "\n");
-	}
-
-      valid_mult_list[data_index] = valid_mult;
-    }
-
-  if (ratio > MAX_RATIO || ratio < -MAX_RATIO)
-    return false;
-
-  return bitmap_bit_p (valid_mult, ratio + MAX_RATIO);
-}
-
  /* Calculate the SPEED or size cost of shiftadd EXPR in MODE.  MULT is the
     EXPR operand holding the shift.  COST0 and COST1 are the costs for
     calculating the operands of EXPR.  Returns true if successful, and returns
diff --git a/gcc/tree-ssa-loop-ivopts.h b/gcc/tree-ssa-loop-ivopts.h
index 004a2c9..f8f31e9 100644
--- a/gcc/tree-ssa-loop-ivopts.h
+++ b/gcc/tree-ssa-loop-ivopts.h
@@ -29,8 +29,6 @@  extern bool contains_abnormal_ssa_name_p (tree);
 extern struct loop *outermost_invariant_loop_for_expr (struct loop *, tree);
 extern bool expr_invariant_in_loop_p (struct loop *, tree);
 bool may_be_nonaddressable_p (tree expr);
-bool multiplier_allowed_in_address_p (HOST_WIDE_INT, machine_mode,
-				      addr_space_t);
 void tree_ssa_iv_optimize (void);
 
 #endif /* GCC_TREE_SSA_LOOP_IVOPTS_H */