This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

IRA memory cost calculation


I've run into a situation where assign_hard_reg()
decides that there are no registers available.  This
results in a memory reference being substituted for a
pseudo-register.  There's no check to see if the modified
instruction is valid, which it isn't.

There are a lot of live registers and it is possible
that there are no unused register.  assign_hard_reg()
is finding that the cost of using any of the registers
it checks is higher than the cost of a memory reference.

I looked at record_operand_costs() and record_reg_classes().
This is supposed to calculate the cost of using memory
or a hard reg for an insn's operands.  Since none of the
constraints permit a memory reference, I would expect that
the mem_cost calculated for each operand would be a high
value; instead it is low.   If I force the mem_cost value
to be high, then assign_hard_reg() does assign a register.

record_operand_costs() does initialize op_costs[] to
high values, both for memory and registers.  This is
reset in record_reg_classes() to the value from
ira_memory_move_cost[] in the following code:

   /* If the alternative actually allows memory, make
      things a bit cheaper since we won't need an extra
      insn to load it.  */
   pp->mem_cost
     = ((recog_data.operand_type[i] != OP_IN
         ? ira_memory_move_cost[mode][classes[i]][0] : 0)
     + (recog_data.operand_type[i] != OP_OUT
         ? ira_memory_move_cost[mode][classes[i]][1] : 0)
     - allows_mem[i]) * frequency;

The alternative doesn't allow memory, so I'm unclear why
mem_cost is being set.  allows_mem[] is zero for all
operands in the insn.


Can anyone give me some guidance here?


--
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]