`reg_qty' records what quantity a register is currently thought
of as containing.
- All real quantity numbers are greater than or equal to `max_reg'.
- If register N has not been assigned a quantity, reg_qty[N] will equal N.
+ All real quantity numbers are greater than or equal to zero.
+ If register N has not been assigned a quantity, reg_qty[N] will
+ equal -N - 1, which is always negative.
- Quantity numbers below `max_reg' do not exist and none of the `qty_table'
- entries should be referenced with an index below `max_reg'.
+ Quantity numbers below zero do not exist and none of the `qty_table'
+ entries should be referenced with a negative index.
We also maintain a bidirectional chain of registers for each
quantity number. The `qty_table` members `first_reg' and `last_reg',
static int do_not_record;
-#ifdef LOAD_EXTEND_OP
-
-/* Scratch rtl used when looking for load-extended copy of a MEM. */
-static rtx memory_extend_rtx;
-#endif
-
/* canon_hash stores 1 in hash_arg_in_memory
if it notices a reference to memory within the expression being hashed. */
of 0. Next come pseudos with a cost of one and other hard registers with
a cost of 2. Aside from these special cases, call `rtx_cost'. */
-#define CHEAP_REGNO(N) \
- ((N) == FRAME_POINTER_REGNUM || (N) == HARD_FRAME_POINTER_REGNUM \
- || (N) == STACK_POINTER_REGNUM || (N) == ARG_POINTER_REGNUM \
- || ((N) >= FIRST_VIRTUAL_REGISTER && (N) <= LAST_VIRTUAL_REGISTER) \
- || ((N) < FIRST_PSEUDO_REGISTER \
+#define CHEAP_REGNO(N) \
+ (REGNO_PTR_FRAME_P(N) \
+ || (HARD_REGISTER_NUM_P (N) \
&& FIXED_REGNO_P (N) && REGNO_REG_CLASS (N) != NO_REGS))
#define COST(X) (REG_P (X) ? 0 : notreg_cost (X, SET))
/* Determine if the quantity number for register X represents a valid index
into the qty_table. */
-#define REGNO_QTY_VALID_P(N) (REG_QTY (N) != (int) (N))
+#define REGNO_QTY_VALID_P(N) (REG_QTY (N) >= 0)
static struct table_elt *table[HASH_SIZE];
p->reg_tick = 1;
p->reg_in_table = -1;
p->subreg_ticked = -1;
- p->reg_qty = regno;
+ p->reg_qty = -regno - 1;
p->regno = regno;
p->next = cse_reg_info_used_list;
cse_reg_info_used_list = p;
{
int i;
- next_qty = max_reg;
+ next_qty = 0;
/* Clear out hash table state for this pass. */
int p, n;
/* If invalid, do nothing. */
- if (q == (int) reg)
+ if (! REGNO_QTY_VALID_P (reg))
return;
ent = &qty_table[q];
else
ent->first_reg = n;
- REG_QTY (reg) = reg;
+ REG_QTY (reg) = -reg - 1;
}
/* Remove any invalid expressions from the hash table
if (REG_P (exp))
{
- need_rehash = (unsigned) REG_QTY (REGNO (exp)) != REGNO (exp);
+ need_rehash = REGNO_QTY_VALID_P (REGNO (exp));
delete_reg_equiv (REGNO (exp));
}
&& MEM_P (src) && ! do_not_record
&& LOAD_EXTEND_OP (mode) != UNKNOWN)
{
+ struct rtx_def memory_extend_buf;
+ rtx memory_extend_rtx = &memory_extend_buf;
enum machine_mode tmode;
/* Set what we are trying to extend and the operation it might
have been extended with. */
+ memset (memory_extend_rtx, 0, sizeof(*memory_extend_rtx));
PUT_CODE (memory_extend_rtx, LOAD_EXTEND_OP (mode));
XEXP (memory_extend_rtx, 0) = src;
|| (GET_CODE (trial) == LABEL_REF
&& ! condjump_p (insn))))
{
+ /* Don't substitute non-local labels, this confuses CFG. */
+ if (GET_CODE (trial) == LABEL_REF
+ && LABEL_REF_NONLOCAL_P (trial))
+ continue;
+
SET_SRC (sets[i].rtl) = trial;
cse_jumps_altered = 1;
break;
if (REG_P (dest) || GET_CODE (dest) == SUBREG)
invalidate (dest, VOIDmode);
else if (MEM_P (dest))
- {
- /* Outgoing arguments for a libcall don't
- affect any recorded expressions. */
- if (! libcall_insn || insn == libcall_insn)
- invalidate (dest, VOIDmode);
- }
+ invalidate (dest, VOIDmode);
else if (GET_CODE (dest) == STRICT_LOW_PART
|| GET_CODE (dest) == ZERO_EXTRACT)
invalidate (XEXP (dest, 0), GET_MODE (dest));
if (REG_P (dest) || GET_CODE (dest) == SUBREG)
invalidate (dest, VOIDmode);
else if (MEM_P (dest))
- {
- /* Outgoing arguments for a libcall don't
- affect any recorded expressions. */
- if (! libcall_insn || insn == libcall_insn)
- invalidate (dest, VOIDmode);
- }
+ invalidate (dest, VOIDmode);
else if (GET_CODE (dest) == STRICT_LOW_PART
|| GET_CODE (dest) == ZERO_EXTRACT)
invalidate (XEXP (dest, 0), GET_MODE (dest));
reg_eqv_table = xmalloc (nregs * sizeof (struct reg_eqv_elem));
-#ifdef LOAD_EXTEND_OP
-
- /* Allocate scratch rtl here. cse_insn will fill in the memory reference
- and change the code and mode as appropriate. */
- memory_extend_rtx = gen_rtx_ZERO_EXTEND (VOIDmode, NULL_RTX);
-#endif
-
/* Reset the counter indicating how many elements have been made
thus far. */
n_elements_made = 0;
INSN_CUID (insn) = i;
}
- ggc_push_context ();
-
/* Loop over basic blocks.
Compute the maximum number of qty's needed for each basic block
(which is 2 for each SET). */
if (max_qty < 500)
max_qty = 500;
- max_qty += max_reg;
-
/* If this basic block is being extended by following certain jumps,
(see `cse_end_of_basic_block'), we reprocess the code from the start.
Otherwise, we start after this basic block. */
#endif
}
- ggc_pop_context ();
-
if (max_elements_made < n_elements_made)
max_elements_made = n_elements_made;
/* Process a single basic block. FROM and TO and the limits of the basic
block. NEXT_BRANCH points to the branch path when following jumps or
- a null path when not following jumps.
-
- AROUND_LOOP is nonzero if we are to try to cse around to the start of a
- loop. This is true when we are being called for the last time on a
- block and this CSE pass is before loop.c. */
+ a null path when not following jumps. */
static rtx
cse_basic_block (rtx from, rtx to, struct branch_path *next_branch)
int num_insns = 0;
int no_conflict = 0;
- /* This array is undefined before max_reg, so only allocate
- the space actually needed and adjust the start. */
-
- qty_table = xmalloc ((max_qty - max_reg) * sizeof (struct qty_table_elem));
- qty_table -= max_reg;
+ /* Allocate the space needed by qty_table. */
+ qty_table = xmalloc (max_qty * sizeof (struct qty_table_elem));
new_basic_block ();
{
if (to == 0)
{
- free (qty_table + max_reg);
+ free (qty_table);
return 0;
}
/* If TO was the last insn in the function, we are done. */
if (insn == 0)
{
- free (qty_table + max_reg);
+ free (qty_table);
return 0;
}
prev = prev_nonnote_insn (to);
if (prev && BARRIER_P (prev))
{
- free (qty_table + max_reg);
+ free (qty_table);
return insn;
}
gcc_assert (next_qty <= max_qty);
- free (qty_table + max_reg);
+ free (qty_table);
return to ? NEXT_INSN (to) : 0;
}
rtx last_insns[2];
unsigned int i;
rtx newreg;
+ edge_iterator ei;
/* We expect to have two successors. Look at both before picking
the final mode for the comparison. If we have more successors
found_equiv = false;
mode = GET_MODE (cc_src);
insn_count = 0;
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
{
rtx insn;
rtx end;
if (e->flags & EDGE_COMPLEX)
continue;
- if (! e->dest->pred
- || e->dest->pred->pred_next
+ if (EDGE_COUNT (e->dest->preds) != 1
|| e->dest == EXIT_BLOCK_PTR)
continue;