This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Use REG_EQUIV/REG_EQUAL notes for loads from MEM_READONLY_P memory in var-tracking (PR debug/43299)
On Tue, Mar 09, 2010 at 04:31:59PM +0100, Richard Guenther wrote:
> > +/* Adjust sets if needed. Currently this optimizes read-only MEM loads
> > + if REG_EQUAL/REG_EQUIV note is present. */
> > +
> > +static void
> > +adjust_sets (rtx insn, struct cselib_set *sets, int n_sets)
> > +{
> > + if (n_sets == 1 && MEM_P (sets[0].src) && MEM_READONLY_P (sets[0].src))
>
> not CONSTANT_P () here?
Yes, a MEM is never a CONSTANT_P. This place changes the MEM/u into
a CONSTANT if there is such a note.
> > + {
> > + /* For read-only MEMs containing some constant, prefer those
> > + constants. */
> > + rtx note = find_reg_equal_equiv_note (insn), src;
> > +
> > + if (note && CONSTANT_P (XEXP (note, 0)))
CONSTANT_P check is here: ^^^^^^^
> > + {
> > + sets[0].src = src = XEXP (note, 0);
> > + if (GET_CODE (PATTERN (insn)) == COND_EXEC)
> > + src = gen_rtx_IF_THEN_ELSE (GET_MODE (sets[0].dest),
> > + COND_EXEC_TEST (PATTERN (insn)),
> > + src, sets[0].dest);
> > + sets[0].src_elt = cselib_lookup (src, GET_MODE (sets[0].dest), 1);
> > + }
> > + }
> > +}
> > +
> > @@ -4971,7 +4997,15 @@ add_stores (rtx loc, const_rtx expr, voi
> > else
> > {
> > if (GET_CODE (expr) == SET && SET_DEST (expr) == loc)
> > - src = var_lowpart (mode2, SET_SRC (expr));
> > + {
> > + if (cui->n_sets == 1
> > + && MEM_P (SET_SRC (expr))
> > + && MEM_READONLY_P (SET_SRC (expr))
> > + && CONSTANT_P (cui->sets[0].src))
>
> this pattern might go into a new predicate?
Well, if you think it is too long, I guess a function returning
the new src would be better than predicate. I.e.
static inline rtx
get_actual_src (struct count_use_info *cui, rtx src)
{
if (cui->n_sets == 1
&& MEM_P (src)
&& MEM_READONLY_P (src)
&& CONSTANT_P (cui->sets[0].src))
return cui->sets[0].src;
return src;
}
and then use
src = var_lowpart (mode2, get_actual_src (cui,
SET_SRC (expr)));
etc.
Jakub