recog: Add a class for propagating into insns
This patch adds yet another way of propagating into an instruction and
simplifying the result. (The net effect of the series is to keep the
total number of propagation approaches the same though, since a later
patch removes the fwprop.c routines.)
One of the drawbacks of the validate_replace_* routines is that
they only do simple simplifications, mostly canonicalisations:
/* Do changes needed to keep rtx consistent. Don't do any other
simplifications, as it is not our job. */
if (simplify)
simplify_while_replacing (loc, to, object, op0_mode);
But substituting can often lead to real simplification opportunities.
simplify-rtx.c:simplify_replace_rtx does fully simplify the result,
but it only operates on specific rvalues rather than full instruction
patterns. It is also nondestructive, which means that it returns a
new rtx whenever a substitution or simplification was possible.
This can create quite a bit of garbage rtl in the context of a
speculative recog, where changing the contents of a pointer is
often enough.
The new routines are therefore supposed to provide simplify_replace_rtx-
style substitution in recog. They go to some effort to prevent garbage
rtl from being created.
At the moment, the new routines fail if the pattern would still refer
to the old "from" value in some way. That might be unnecessary in
some contexts; if so, it could be put behind a configuration parameter.
gcc/
* recog.h (insn_propagation): New class.
* recog.c (insn_propagation::apply_to_mem_1): New function.
(insn_propagation::apply_to_rvalue_1): Likewise.
(insn_propagation::apply_to_lvalue_1): Likewise.
(insn_propagation::apply_to_pattern_1): Likewise.
(insn_propagation::apply_to_pattern): Likewise.
(insn_propagation::apply_to_rvalue): Likewise.