Patch: Fix match_dup handling in web.c

Steven Bosscher stevenb.gcc@gmail.com
Thu Mar 25 09:32:00 GMT 2010


On Thu, Mar 25, 2010 at 12:19 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> On Wed, Mar 24, 2010 at 11:25 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
>> I found a number of bugs while testing an ARM patch that rewrites the
>> ldm/stm peepholes.
>>
>> In web.c, there is code that tries to detect match_dups by comparing
>> operands for equality; this is neither a necessary nor a sufficient
>> condition.  In particular, web.c cannot detect an input operand that
>> match_dups an in-out output operand; this can result in web.c breaking
>> match_dups and replacing only the inputs of an insn.
>
> Hmm, this has always worked ever since web.c was contributed years
> ago, you'd think that such a deficiency would have been a problem for
> someone by now.

Reading md.texi:

Note that @code{match_dup} should not be used to tell the compiler that
a particular register is being used for two operands (example:
@code{add} that adds one register to another; the second register is
both an input operand and the output operand).  Use a matching
constraint (@pxref{Simple Constraints}) for those.

Are you sure your pattern shouldn't use a constraint instead of a
match_dup? (I realize it's kind-of inappropriate, me asking this to
you with so much more experience with machine descriptions -- but it
just strikes me as odd that web.c has worked for years with such a
seemingly serious bug in it.)

Ciao!
Steven



More information about the Gcc-patches mailing list