Hi!
On Wed, Oct 09, 2019 at 04:03:16PM -0400, Michael Meissner wrote:
> The basic problem is if there is no explicit cost predicate, rs6000_insn_cost
> uses the instruction size to figure out how many instructions are present, and
> make the cost a fact on that. Since prefixed instructions are 12 bytes within
> GCC (to deal with the implicit NOP), if we did not do this change, the
> optimizers would try to save registers from prefixed loads because they
> thought
> the load was more expensive.
Maybe we should just have an attribute that says how many insns this is?
You can get rid of many prefixed_length and non_prefixed_length attributes
that way, too.
> + int cost;
> + int length = get_attr_length (insn);
> + int n = length / 4;
> +
> + /* How many real instructions are generated for this insn? This is
> slightly
What is a "real" instruction? Machine instruction?
> + different from the length attribute, in that the length attribute counts
> + the number of bytes. With prefixed instructions, we don't want to
> count a
> + prefixed instruction (length 12 bytes including possible NOP) as taking
> 3
> + instructions, but just one. */
> + if (length >= 12 && get_attr_prefixed (insn) == PREFIXED_YES)
> + {
> + /* Single prefixed instruction. */
> + if (length == 12)
> + n = 1;
> +
> + /* A normal instruction and a prefixed instruction (16) or two back
> + to back prefixed instructions (20). */
> + else if (length == 16 || length == 20)
> + n = 2;
> +
> + /* Guess for larger instruction sizes. */
> + else
> + n = 2 + (length - 20) / 4;
That's a pretty bad estimate.
Can you look at non_prefixed_size, will that help?
Segher