Cleaning up expand optabs code

Richard Sandiford richard.sandiford@linaro.org
Fri Mar 25 17:56:00 GMT 2011


Richard Henderson <rth@redhat.com> writes:
> This is due to a miscommunication between the middle-end and the backend
> about how many arguments the setmemhi pattern takes.
>
> (define_expand "setmemhi"
>   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
>                    (match_operand 2 "const_int_operand" ""))
>               (use (match_operand:HI 1 "const_int_operand" ""))
>               (use (match_operand:HI 3 "const_int_operand" "n"))
>               (clobber (match_scratch:HI 4 ""))
>               (clobber (match_dup 5))])]
>
> The match_scratch is counted in .n_operands, which makes the count of
> operands not equal 4, so we assume 6 operands are necessary.  We can
> fix this for the special case of avr by only assuming 6 operands when
> there are in fact 6 operands, but of course this could fail just as
> easily if there were two scratches.
>
> All of which suggests that optional arguments to a named optab is a
> mistake that ought to be rectified.
>
> I plan to commit the following after bootstrap and check.

Thanks.  I think it needs to be s/!= 4/>= 6/ though, so that
match_scratches still work when 6 operands really are passed in.

Fully agreed on the optional args thing.  Or maybe insn_data should
have a separate "num_args" field.

Richard



More information about the Gcc-patches mailing list