On Thu, Jun 20, 2019 at 9:40 AM Uros Bizjak <ubiz...@gmail.com> wrote: > > On Mon, Jun 17, 2019 at 6:27 PM H.J. Lu <hjl.to...@gmail.com> wrote: > > > > processor_costs has costs of RTL expressions and costs of moves: > > > > 1. Costs of RTL expressions is computed as COSTS_N_INSNS which are used > > to generate RTL expressions with the lowest costs. Costs of RTL memory > > operation can be very close to costs of fast instructions to indicate > > fast memory operations. > > > > 2. After RTL expressions have been generated, costs of moves are used by > > TARGET_REGISTER_MOVE_COST and TARGET_MEMORY_MOVE_COST to compute move > > costs for register allocator. Costs of load and store are higher than > > costs of register moves to reduce stack usages by register allocator. > > > > We should separate costs of RTL expressions from costs of moves so that > > they can be adjusted independently. This patch moves costs of moves to > > the new used_by_ra field and duplicates costs of moves which are also > > used for costs of RTL expressions. > > Actually, I think that the current separation is OK. Before reload, we > actually don't know which register set will perform the move (not even > if float mode will be moved in integer registers), the only thing we > can estimate is the number of move instructions. The real cost of > register moves is later calculated by the register allocator, where > the register class is taken into account when calculating the cost.
Forgot to say that due to the above reasoning, cost of moves should not be used in the calculation of costs of RTL expressions, as we are talking about two different cost functions. RTL expressions should know nothing about register classes. Uros. > > > > > All cost models have been checked with > > > > static void > > check_one (const struct processor_costs *p) > > { > > if (p->used_by_ra.int_load[2] != p->int_load) > > abort (); > > if (p->used_by_ra.int_store[2] != p->int_store) > > abort (); > > if (p->used_by_ra.xmm_move != p->xmm_move) > > abort (); > > if (p->used_by_ra.sse_to_integer != p->sse_to_integer) > > abort (); > > if (p->used_by_ra.integer_to_sse != p->integer_to_sse) > > abort (); > > if (memcmp (p->used_by_ra.sse_load, p->sse_load, sizeof (p->sse_load))) > > abort (); > > if (memcmp (p->used_by_ra.sse_store, p->sse_store, sizeof (p->sse_store))) > > abort (); > > } > > > > static void > > check_cost () > > { > > check_one (&ix86_size_cost); > > for (unsigned int i = 0; i < ARRAY_SIZE (processor_cost_table); i++) > > check_one (processor_cost_table[i]); > > } > > > > by calling check_cost from ix86_option_override_internal. > > > > PR target/90878 > > * config/i386/i386-features.c > > (dimode_scalar_chain::compute_convert_gain): Replace int_store[2] > > and int_load[2] with int_store and int_load. > > * config/i386/i386.c (inline_memory_move_cost): Use used_by_ra > > for costs of moves. > > (ix86_register_move_cost): Likewise. > > (ix86_builtin_vectorization_cost): Replace int_store[2] and > > int_load[2] with int_store and int_load. > > * config/i386/i386.h (processor_costs): Move costs of moves to > > used_by_ra. Add int_load, int_store, xmm_move, sse_to_integer, > > integer_to_sse, sse_load, sse_store, sse_unaligned_load and > > sse_unaligned_store for costs of RTL expressions. > > * config/i386/x86-tune-costs.h: Duplicate int_load, int_store, > > xmm_move, sse_to_integer, integer_to_sse, sse_load, sse_store > > for costs of RTL expressions. Use sse_unaligned_load and > > sse_unaligned_store only for costs of RTL expressions. > > > > -- > > H.J.