This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Prefer reg as first operand in commutative operator
On 14/02/12 14:10, Jakub Jelinek wrote:
On Tue, Feb 14, 2012 at 02:05:30PM +0000, Paulo J. Matos wrote:
I think the register allocator will generate good code using % if you
make your predicate nonimmediate_operand in operand 1:
[(set (match_operand:QI 0 "register_operand" "=c")
(ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
(match_operand:QI 2 "general_operand" "cwmi")))
(clobber (reg:CC RCC))]
"register_operand(operands, QImode) ||
Yes, I think in general that seems to be the right procedure. In my
case, unfortunately it does not work.
The reason is that it allows:
(set (reg:QI ...)
(ior:QI (mem:QI (reg:QI ...))
(mem:QI (reg:QI ...))))
This wouldn't in general be a problem except that my backend only
has one register that can be used for a memory dereference, which
means that BASE_REG_CLASS is a class with a single register.
It doesn't allow that, because the condition on the insn then fails,
as neither operand 1 nor operand 2 is register_operand.
It doesn't look like you can actually do that because, according to the
"For a named pattern, the condition (if present) may not depend on the
data in the insn being matched, but only the target-machine-type flags.
The compiler needs to test these conditions during initialization in
order to learn exactly which named instructions are available in a
And GCC complains with:
insn-opinit.c: In function 'init_all_optabs':
insn-opinit.c:24: error: 'operands' undeclared (first use in this function)
insn-opinit.c:24: error: (Each undeclared identifier is reported only once
insn-opinit.c:24: error: for each function it appears in.)
Did I miss something in the example?