Commit cd047059 by Bin Cheng Committed by Bin Cheng

tree-ssa-loop-ivopts.c (enum ainc_type): New.

	* tree-ssa-loop-ivopts.c (enum ainc_type): New.
	(address_cost_data): New field.
	(get_address_cost): Compute auto-increment rtx cost in ainc_costs.
	Use ainc_costs for auto-increment rtx patterns.
	Cleanup TWS.

From-SVN: r205015
parent c1dfcec7
2013-11-19 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (enum ainc_type): New.
(address_cost_data): New field.
(get_address_cost): Compute auto-increment rtx cost in ainc_costs.
Use ainc_costs for auto-increment rtx patterns.
Cleanup TWS.
2013-11-19 James Greenhalgh <james.greenhalgh@arm.com> 2013-11-19 James Greenhalgh <james.greenhalgh@arm.com>
* config/aarch64/aarch64.md: Remove v8type from all insns. * config/aarch64/aarch64.md: Remove v8type from all insns.
...@@ -3207,10 +3207,20 @@ multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode, ...@@ -3207,10 +3207,20 @@ multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode,
TODO -- there must be some better way. This all is quite crude. */ TODO -- there must be some better way. This all is quite crude. */
enum ainc_type
{
AINC_PRE_INC, /* Pre increment. */
AINC_PRE_DEC, /* Pre decrement. */
AINC_POST_INC, /* Post increment. */
AINC_POST_DEC, /* Post decrement. */
AINC_NONE /* Also the number of auto increment types. */
};
typedef struct address_cost_data_s typedef struct address_cost_data_s
{ {
HOST_WIDE_INT min_offset, max_offset; HOST_WIDE_INT min_offset, max_offset;
unsigned costs[2][2][2][2]; unsigned costs[2][2][2][2];
unsigned ainc_costs[AINC_NONE];
} *address_cost_data; } *address_cost_data;
...@@ -3228,6 +3238,7 @@ get_address_cost (bool symbol_present, bool var_present, ...@@ -3228,6 +3238,7 @@ get_address_cost (bool symbol_present, bool var_present,
static bool has_preinc[MAX_MACHINE_MODE], has_postinc[MAX_MACHINE_MODE]; static bool has_preinc[MAX_MACHINE_MODE], has_postinc[MAX_MACHINE_MODE];
static bool has_predec[MAX_MACHINE_MODE], has_postdec[MAX_MACHINE_MODE]; static bool has_predec[MAX_MACHINE_MODE], has_postdec[MAX_MACHINE_MODE];
unsigned cost, acost, complexity; unsigned cost, acost, complexity;
enum ainc_type autoinc_type;
bool offset_p, ratio_p, autoinc; bool offset_p, ratio_p, autoinc;
HOST_WIDE_INT s_offset, autoinc_offset, msize; HOST_WIDE_INT s_offset, autoinc_offset, msize;
unsigned HOST_WIDE_INT mask; unsigned HOST_WIDE_INT mask;
...@@ -3299,33 +3310,49 @@ get_address_cost (bool symbol_present, bool var_present, ...@@ -3299,33 +3310,49 @@ get_address_cost (bool symbol_present, bool var_present,
reg0 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1); reg0 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1);
reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2); reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2);
if (USE_LOAD_PRE_DECREMENT (mem_mode) if (USE_LOAD_PRE_DECREMENT (mem_mode)
|| USE_STORE_PRE_DECREMENT (mem_mode)) || USE_STORE_PRE_DECREMENT (mem_mode))
{ {
addr = gen_rtx_PRE_DEC (address_mode, reg0); addr = gen_rtx_PRE_DEC (address_mode, reg0);
has_predec[mem_mode] has_predec[mem_mode]
= memory_address_addr_space_p (mem_mode, addr, as); = memory_address_addr_space_p (mem_mode, addr, as);
if (has_predec[mem_mode])
data->ainc_costs[AINC_PRE_DEC]
= address_cost (addr, mem_mode, as, speed);
} }
if (USE_LOAD_POST_DECREMENT (mem_mode) if (USE_LOAD_POST_DECREMENT (mem_mode)
|| USE_STORE_POST_DECREMENT (mem_mode)) || USE_STORE_POST_DECREMENT (mem_mode))
{ {
addr = gen_rtx_POST_DEC (address_mode, reg0); addr = gen_rtx_POST_DEC (address_mode, reg0);
has_postdec[mem_mode] has_postdec[mem_mode]
= memory_address_addr_space_p (mem_mode, addr, as); = memory_address_addr_space_p (mem_mode, addr, as);
if (has_postdec[mem_mode])
data->ainc_costs[AINC_POST_DEC]
= address_cost (addr, mem_mode, as, speed);
} }
if (USE_LOAD_PRE_INCREMENT (mem_mode) if (USE_LOAD_PRE_INCREMENT (mem_mode)
|| USE_STORE_PRE_DECREMENT (mem_mode)) || USE_STORE_PRE_DECREMENT (mem_mode))
{ {
addr = gen_rtx_PRE_INC (address_mode, reg0); addr = gen_rtx_PRE_INC (address_mode, reg0);
has_preinc[mem_mode] has_preinc[mem_mode]
= memory_address_addr_space_p (mem_mode, addr, as); = memory_address_addr_space_p (mem_mode, addr, as);
if (has_preinc[mem_mode])
data->ainc_costs[AINC_PRE_INC]
= address_cost (addr, mem_mode, as, speed);
} }
if (USE_LOAD_POST_INCREMENT (mem_mode) if (USE_LOAD_POST_INCREMENT (mem_mode)
|| USE_STORE_POST_INCREMENT (mem_mode)) || USE_STORE_POST_INCREMENT (mem_mode))
{ {
addr = gen_rtx_POST_INC (address_mode, reg0); addr = gen_rtx_POST_INC (address_mode, reg0);
has_postinc[mem_mode] has_postinc[mem_mode]
= memory_address_addr_space_p (mem_mode, addr, as); = memory_address_addr_space_p (mem_mode, addr, as);
if (has_postinc[mem_mode])
data->ainc_costs[AINC_POST_INC]
= address_cost (addr, mem_mode, as, speed);
} }
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
...@@ -3451,21 +3478,31 @@ get_address_cost (bool symbol_present, bool var_present, ...@@ -3451,21 +3478,31 @@ get_address_cost (bool symbol_present, bool var_present,
s_offset = offset; s_offset = offset;
autoinc = false; autoinc = false;
autoinc_type = AINC_NONE;
msize = GET_MODE_SIZE (mem_mode); msize = GET_MODE_SIZE (mem_mode);
autoinc_offset = offset; autoinc_offset = offset;
if (stmt_after_inc) if (stmt_after_inc)
autoinc_offset += ratio * cstep; autoinc_offset += ratio * cstep;
if (symbol_present || var_present || ratio != 1) if (symbol_present || var_present || ratio != 1)
autoinc = false; autoinc = false;
else if ((has_postinc[mem_mode] && autoinc_offset == 0 else
&& msize == cstep) {
|| (has_postdec[mem_mode] && autoinc_offset == 0 if (has_postinc[mem_mode] && autoinc_offset == 0
&& msize == cstep)
autoinc_type = AINC_POST_INC;
else if (has_postdec[mem_mode] && autoinc_offset == 0
&& msize == -cstep) && msize == -cstep)
|| (has_preinc[mem_mode] && autoinc_offset == msize autoinc_type = AINC_POST_DEC;
else if (has_preinc[mem_mode] && autoinc_offset == msize
&& msize == cstep) && msize == cstep)
|| (has_predec[mem_mode] && autoinc_offset == -msize autoinc_type = AINC_PRE_INC;
&& msize == -cstep)) else if (has_predec[mem_mode] && autoinc_offset == -msize
autoinc = true; && msize == -cstep)
autoinc_type = AINC_PRE_DEC;
if (autoinc_type != AINC_NONE)
autoinc = true;
}
cost = 0; cost = 0;
offset_p = (s_offset != 0 offset_p = (s_offset != 0
...@@ -3482,7 +3519,10 @@ get_address_cost (bool symbol_present, bool var_present, ...@@ -3482,7 +3519,10 @@ get_address_cost (bool symbol_present, bool var_present,
if (may_autoinc) if (may_autoinc)
*may_autoinc = autoinc; *may_autoinc = autoinc;
acost = data->costs[symbol_present][var_present][offset_p][ratio_p]; if (autoinc)
acost = data->ainc_costs[autoinc_type];
else
acost = data->costs[symbol_present][var_present][offset_p][ratio_p];
complexity = (symbol_present != 0) + (var_present != 0) + offset_p + ratio_p; complexity = (symbol_present != 0) + (var_present != 0) + offset_p + ratio_p;
return new_cost (cost + acost, complexity); return new_cost (cost + acost, complexity);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment