Re: [PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

2017-11-23 Thread Charles Baylis
On 15 September 2017 at 17:57, Kyrill  Tkachov
 wrote:
>
> Thanks, this is ok once the prerequisites are sorted.

Patch 1 was abandoned, and a later version of patch 2 has been
committed, so this was applied to trunk as r255112.


Re: [PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

2017-09-15 Thread Kyrill Tkachov


On 15/09/17 16:38, Charles Baylis wrote:

On 13 September 2017 at 10:02, Kyrill  Tkachov
 wrote:


Please add a comment here saying that the units are in COSTS_N_INSNS
so that we can reduce the temptation to use these in inappropriate contexts.

+  if (VECTOR_MODE_P (mode))
+   {
+ *cost += current_tune->addr_mode_costs->vector[op_type];
+   }
+  else if (FLOAT_MODE_P (mode))
+   {
+ *cost += current_tune->addr_mode_costs->fp[op_type];
+   }
+  else
+   {
+ *cost += current_tune->addr_mode_costs->integer[op_type];
+   }


No need for brackets for single-statement conditionals.

Done.


Thanks, this is ok once the prerequisites are sorted.

Kyrill


Re: [PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

2017-09-15 Thread Charles Baylis
On 13 September 2017 at 10:02, Kyrill  Tkachov
<kyrylo.tkac...@foss.arm.com> wrote:

>
> Please add a comment here saying that the units are in COSTS_N_INSNS
> so that we can reduce the temptation to use these in inappropriate contexts.

>> +  if (VECTOR_MODE_P (mode))
>> +   {
>> + *cost += current_tune->addr_mode_costs->vector[op_type];
>> +   }
>> +  else if (FLOAT_MODE_P (mode))
>> +   {
>> + *cost += current_tune->addr_mode_costs->fp[op_type];
>> +   }
>> +  else
>> +   {
>> + *cost += current_tune->addr_mode_costs->integer[op_type];
>> +   }
>
>
> No need for brackets for single-statement conditionals.

Done.
From a35fa59f4dc3be42a52519a90bdd2d47e74db086 Mon Sep 17 00:00:00 2001
From: Charles Baylis <charles.bay...@linaro.org>
Date: Thu, 14 Sep 2017 12:47:41 +0100
Subject: [PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

This patch adds support for modelling the varying costs of
different addressing modes. The generic cost table treats
all addressing modes as having equal cost.

gcc/ChangeLog:

  Charles Baylis  <charles.bay...@linaro.org>

	* config/arm/arm-protos.h (enum arm_addr_mode_op): New.
	(struct addr_mode_cost_table): New.
	(struct tune_params): Add field addr_mode_costs.
	* config/arm/arm.c (generic_addr_mode_costs): New.
	(arm_slowmul_tune): Initialise addr_mode_costs field.
	(arm_fastmul_tune): Likewise.
	(arm_strongarm_tune): Likewise.
	(arm_xscale_tune): Likewise.
	(arm_9e_tune): Likewise.
	(arm_marvell_pj4_tune): Likewise.
	(arm_v6t2_tune): Likewise.
	(arm_cortex_tune): Likewise.
	(arm_cortex_a8_tune): Likewise.
	(arm_cortex_a7_tune): Likewise.
	(arm_cortex_a15_tune): Likewise.
	(arm_cortex_a35_tune): Likewise.
	(arm_cortex_a53_tune): Likewise.
	(arm_cortex_a57_tune): Likewise.
	(arm_exynosm1_tune): Likewise.
	(arm_xgene1_tune): Likewise.
	(arm_cortex_a5_tune): Likewise.
	(arm_cortex_a9_tune): Likewise.
	(arm_cortex_a12_tune): Likewise.
	(arm_cortex_a73_tune): Likewise.
	(arm_v7m_tune): Likewise.
	(arm_cortex_m7_tune): Likewise.
	(arm_v6m_tune): Likewise.
	(arm_fa726te_tune): Likewise.
	(arm_mem_costs): Use table lookup to calculate cost of addressing
	mode.

Change-Id: If71bd7c4f4bb876c5ed82dc28791130efb8bf89e
---
 gcc/config/arm/arm-protos.h | 20 +++
 gcc/config/arm/arm.c| 81 +
 2 files changed, 101 insertions(+)

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 47a85cc..7769726 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -261,12 +261,32 @@ struct cpu_vec_costs {
 
 struct cpu_cost_table;
 
+/* Addressing mode operations.  Used to index tables in struct
+   addr_mode_cost_table.  */
+enum arm_addr_mode_op
+{
+   AMO_DEFAULT,
+   AMO_NO_WB,	/* Offset with no writeback.  */
+   AMO_WB,	/* Offset with writeback.  */
+   AMO_MAX	/* For array size.  */
+};
+
+/* Table of additional costs in units of COSTS_N_INSNS() when using
+   addressing modes for each access type.  */
+struct addr_mode_cost_table
+{
+   const int integer[AMO_MAX];
+   const int fp[AMO_MAX];
+   const int vector[AMO_MAX];
+};
+
 /* Dump function ARM_PRINT_TUNE_INFO should be updated whenever this
structure is modified.  */
 
 struct tune_params
 {
   const struct cpu_cost_table *insn_extra_cost;
+  const struct addr_mode_cost_table *addr_mode_costs;
   bool (*sched_adjust_cost) (rtx_insn *, int, rtx_insn *, int *);
   int (*branch_cost) (bool, bool);
   /* Vectorizer costs.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 64230b8..7773ec3 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1751,9 +1751,32 @@ const struct cpu_cost_table v7m_extra_costs =
   }
 };
 
+const struct addr_mode_cost_table generic_addr_mode_costs =
+{
+  /* int.  */
+  {
+COSTS_N_INSNS (0),	/* AMO_DEFAULT.  */
+COSTS_N_INSNS (0),	/* AMO_NO_WB.  */
+COSTS_N_INSNS (0)	/* AMO_WB.  */
+  },
+  /* float.  */
+  {
+COSTS_N_INSNS (0),	/* AMO_DEFAULT.  */
+COSTS_N_INSNS (0),	/* AMO_NO_WB.  */
+COSTS_N_INSNS (0)	/* AMO_WB.  */
+  },
+  /* vector.  */
+  {
+COSTS_N_INSNS (0),	/* AMO_DEFAULT.  */
+COSTS_N_INSNS (0),	/* AMO_NO_WB.  */
+COSTS_N_INSNS (0)	/* AMO_WB.  */
+  }
+};
+
 const struct tune_params arm_slowmul_tune =
 {
   _extra_costs,			/* Insn extra costs.  */
+  _addr_mode_costs,		/* Addressing mode costs.  */
   NULL,	/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1777,6 +1800,7 @@ const struct tune_params arm_slowmul_tune =
 const struct tune_params arm_fastmul_tune =
 {
   _extra_costs,			/* Insn extra costs.  */
+  _addr_mode_costs,		/* Addressing mode costs.  */
   NULL,	/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1803,6 +1827,7 @@ const struct tune_params arm_fa

Re: [PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

2017-09-15 Thread Charles Baylis
On 13 September 2017 at 10:02, Kyrill  Tkachov
 wrote:

>
> Please add a comment here saying that the units are in COSTS_N_INSNS
> so that we can reduce the temptation to use these in inappropriate contexts.

>> +  if (VECTOR_MODE_P (mode))
>> +   {
>> + *cost += current_tune->addr_mode_costs->vector[op_type];
>> +   }
>> +  else if (FLOAT_MODE_P (mode))
>> +   {
>> + *cost += current_tune->addr_mode_costs->fp[op_type];
>> +   }
>> +  else
>> +   {
>> + *cost += current_tune->addr_mode_costs->integer[op_type];
>> +   }
>
>
> No need for brackets for single-statement conditionals.

Done.


Re: [PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

2017-09-13 Thread Kyrill Tkachov

Hi Charles,

On 12/09/17 09:34, charles.bay...@linaro.org wrote:

From: Charles Baylis 

This patch adds support for modelling the varying costs of
different addressing modes. The generic cost table treats
all addressing modes as having equal cost.

gcc/ChangeLog:

  Charles Baylis 

* config/arm/arm-protos.h (enum arm_addr_mode_op): New.
(struct addr_mode_cost_table): New.
(struct tune_params): Add field addr_mode_costs.
* config/arm/arm.c (generic_addr_mode_costs): New.
(arm_slowmul_tune): Initialise addr_mode_costs field.
(arm_fastmul_tune): Likewise.
(arm_strongarm_tune): Likewise.
(arm_xscale_tune): Likewise.
(arm_9e_tune): Likewise.
(arm_marvell_pj4_tune): Likewise.
(arm_v6t2_tune): Likewise.
(arm_cortex_tune): Likewise.
(arm_cortex_a8_tune): Likewise.
(arm_cortex_a7_tune): Likewise.
(arm_cortex_a15_tune): Likewise.
(arm_cortex_a35_tune): Likewise.
(arm_cortex_a53_tune): Likewise.
(arm_cortex_a57_tune): Likewise.
(arm_exynosm1_tune): Likewise.
(arm_xgene1_tune): Likewise.
(arm_cortex_a5_tune): Likewise.
(arm_cortex_a9_tune): Likewise.
(arm_cortex_a12_tune): Likewise.
(arm_cortex_a73_tune): Likewise.
(arm_v7m_tune): Likewise.
(arm_cortex_m7_tune): Likewise.
(arm_v6m_tune): Likewise.
(arm_fa726te_tune): Likewise.
(arm_mem_costs): Use table lookup to calculate cost of addressing
mode.

Change-Id: If71bd7c4f4bb876c5ed82dc28791130efb8bf89e
---
 gcc/config/arm/arm-protos.h | 20 +++
 gcc/config/arm/arm.c| 83 
-

 2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 47a85cc..3d6b515 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -261,12 +261,32 @@ struct cpu_vec_costs {

 struct cpu_cost_table;

+/* Addressing mode operations.  Used to index tables in struct
+   addr_mode_cost_table.  */
+enum arm_addr_mode_op
+{
+   AMO_DEFAULT,
+   AMO_NO_WB,  /* Offset with no writeback.  */
+   AMO_WB, /* Offset with writeback.  */
+   AMO_MAX /* For array size.  */
+};
+
+/* Table of additional costs when using addressing modes for each
+   access type.  */


Please add a comment here saying that the units are in COSTS_N_INSNS
so that we can reduce the temptation to use these in inappropriate contexts.


+struct addr_mode_cost_table
+{
+   const int integer[AMO_MAX];
+   const int fp[AMO_MAX];
+   const int vector[AMO_MAX];
+};
+
 /* Dump function ARM_PRINT_TUNE_INFO should be updated whenever this
structure is modified.  */

 struct tune_params
 {
   const struct cpu_cost_table *insn_extra_cost;
+  const struct addr_mode_cost_table *addr_mode_costs;
   bool (*sched_adjust_cost) (rtx_insn *, int, rtx_insn *, int *);
   int (*branch_cost) (bool, bool);
   /* Vectorizer costs.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index b8dbed6..0d31f5f 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1751,9 +1751,32 @@ const struct cpu_cost_table v7m_extra_costs =
   }
 };

+const struct addr_mode_cost_table generic_addr_mode_costs =
+{
+  /* int.  */
+  {
+0,  /* AMO_DEFAULT.  */
+0,  /* AMO_NO_WB.  */
+0   /* AMO_WB.  */
+  },
+  /* float.  */
+  {
+0,  /* AMO_DEFAULT.  */
+0,  /* AMO_NO_WB.  */
+0   /* AMO_WB.  */
+  },
+  /* vector.  */
+  {
+0,  /* AMO_DEFAULT.  */
+0,  /* AMO_NO_WB.  */
+0   /* AMO_WB.  */
+  }
+};
+
 const struct tune_params arm_slowmul_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   NULL,/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1777,6 +1800,7 @@ const struct tune_params arm_slowmul_tune =
 const struct tune_params arm_fastmul_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   NULL,/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1803,6 +1827,7 @@ const struct tune_params arm_fastmul_tune =
 const struct tune_params arm_strongarm_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   NULL,/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1826,6 +1851,7 @@ const struct tune_params arm_strongarm_tune =
 const struct tune_params arm_xscale_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   xscale_sched_adjust_cost,
   

[PATCH 3/3] [ARM] Add table of costs for AAarch32 addressing modes.

2017-09-12 Thread charles . baylis
From: Charles Baylis 

This patch adds support for modelling the varying costs of
different addressing modes. The generic cost table treats
all addressing modes as having equal cost.

gcc/ChangeLog:

  Charles Baylis  

* config/arm/arm-protos.h (enum arm_addr_mode_op): New.
(struct addr_mode_cost_table): New.
(struct tune_params): Add field addr_mode_costs.
* config/arm/arm.c (generic_addr_mode_costs): New.
(arm_slowmul_tune): Initialise addr_mode_costs field.
(arm_fastmul_tune): Likewise.
(arm_strongarm_tune): Likewise.
(arm_xscale_tune): Likewise.
(arm_9e_tune): Likewise.
(arm_marvell_pj4_tune): Likewise.
(arm_v6t2_tune): Likewise.
(arm_cortex_tune): Likewise.
(arm_cortex_a8_tune): Likewise.
(arm_cortex_a7_tune): Likewise.
(arm_cortex_a15_tune): Likewise.
(arm_cortex_a35_tune): Likewise.
(arm_cortex_a53_tune): Likewise.
(arm_cortex_a57_tune): Likewise.
(arm_exynosm1_tune): Likewise.
(arm_xgene1_tune): Likewise.
(arm_cortex_a5_tune): Likewise.
(arm_cortex_a9_tune): Likewise.
(arm_cortex_a12_tune): Likewise.
(arm_cortex_a73_tune): Likewise.
(arm_v7m_tune): Likewise.
(arm_cortex_m7_tune): Likewise.
(arm_v6m_tune): Likewise.
(arm_fa726te_tune): Likewise.
(arm_mem_costs): Use table lookup to calculate cost of addressing
mode.

Change-Id: If71bd7c4f4bb876c5ed82dc28791130efb8bf89e
---
 gcc/config/arm/arm-protos.h | 20 +++
 gcc/config/arm/arm.c| 83 -
 2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 47a85cc..3d6b515 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -261,12 +261,32 @@ struct cpu_vec_costs {
 
 struct cpu_cost_table;
 
+/* Addressing mode operations.  Used to index tables in struct
+   addr_mode_cost_table.  */
+enum arm_addr_mode_op
+{
+   AMO_DEFAULT,
+   AMO_NO_WB,  /* Offset with no writeback.  */
+   AMO_WB, /* Offset with writeback.  */
+   AMO_MAX /* For array size.  */
+};
+
+/* Table of additional costs when using addressing modes for each
+   access type.  */
+struct addr_mode_cost_table
+{
+   const int integer[AMO_MAX];
+   const int fp[AMO_MAX];
+   const int vector[AMO_MAX];
+};
+
 /* Dump function ARM_PRINT_TUNE_INFO should be updated whenever this
structure is modified.  */
 
 struct tune_params
 {
   const struct cpu_cost_table *insn_extra_cost;
+  const struct addr_mode_cost_table *addr_mode_costs;
   bool (*sched_adjust_cost) (rtx_insn *, int, rtx_insn *, int *);
   int (*branch_cost) (bool, bool);
   /* Vectorizer costs.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index b8dbed6..0d31f5f 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1751,9 +1751,32 @@ const struct cpu_cost_table v7m_extra_costs =
   }
 };
 
+const struct addr_mode_cost_table generic_addr_mode_costs =
+{
+  /* int.  */
+  {
+0,  /* AMO_DEFAULT.  */
+0,  /* AMO_NO_WB.  */
+0   /* AMO_WB.  */
+  },
+  /* float.  */
+  {
+0,  /* AMO_DEFAULT.  */
+0,  /* AMO_NO_WB.  */
+0   /* AMO_WB.  */
+  },
+  /* vector.  */
+  {
+0,  /* AMO_DEFAULT.  */
+0,  /* AMO_NO_WB.  */
+0   /* AMO_WB.  */
+  }
+};
+
 const struct tune_params arm_slowmul_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   NULL,/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1777,6 +1800,7 @@ const struct tune_params arm_slowmul_tune =
 const struct tune_params arm_fastmul_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   NULL,/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1803,6 +1827,7 @@ const struct tune_params arm_fastmul_tune =
 const struct tune_params arm_strongarm_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   NULL,/* Sched adj cost.  */
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1826,6 +1851,7 @@ const struct tune_params arm_strongarm_tune =
 const struct tune_params arm_xscale_tune =
 {
   _extra_costs,/* Insn extra costs.  */
+  _addr_mode_costs,/* Addressing mode costs.  */
   xscale_sched_adjust_cost,
   arm_default_branch_cost,
   _default_vec_cost,
@@ -1849,6 +1875,7 @@ const struct tune_params arm_xscale_tune =
 const struct tune_params arm_9e_tune =
 {
   _extra_costs,/* Insn extra costs.  */