public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Matching Constraints and Predicate
@ 2010-08-23 14:26 Paulo J. Matos
  2010-08-23 18:06 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Paulo J. Matos @ 2010-08-23 14:26 UTC (permalink / raw)
  To: gcc

Hello,

I am quite confused with the following from the internals:
; Operand predicates can allow operands that are not actually
; acceptable to the hardware, as long as the constraints give
; reload the ability to fix them up (see Constraints). However,
; GCC will usually generate better code if the predicates specify
; the requirements of the machine instructions as closely as
; possible. Reload cannot fix up operands that must be
; constants (immediate operands); you must use a predicate that
; allows only constants, or else enforce the requirement in the
; extra condition.

This seems to imply that if the predicates specify the same
requirements of constraints, then resulting code if better.

However, if I have register constraints that define constraint x to
match a certain register class X and I define predicate:
(define_predicate "x_operand"
    (and (match_operand 0 "register_operand")
             (match_test "REGNO_REG_CLASS(REGNO(op)) == X")))

and then I have a match_operand on an insn (match_operand 0
"x_operand" "x") this is quite disastrous as gcc promptly stops since
any pseudo-register during will fail the predicate and no rule will
not be matched.
It feels like I should say in the predicate something like: it's
either a pseudo, or a register from X.

What am I misinterpreting?

Cheers,

-- 
PMatos

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Matching Constraints and Predicate
  2010-08-23 14:26 Matching Constraints and Predicate Paulo J. Matos
@ 2010-08-23 18:06 ` Ian Lance Taylor
  2010-08-24 13:36   ` Paulo J. Matos
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2010-08-23 18:06 UTC (permalink / raw)
  To: Paulo J. Matos; +Cc: gcc

"Paulo J. Matos" <pocmatos@gmail.com> writes:

> However, if I have register constraints that define constraint x to
> match a certain register class X and I define predicate:
> (define_predicate "x_operand"
>     (and (match_operand 0 "register_operand")
>              (match_test "REGNO_REG_CLASS(REGNO(op)) == X")))

As you observe, this is wrong.  A pseudo-register has no register class.
You can only test the register class if you first test that you have a
hard register.

This also makes no sense.  The operand predicate should test whether the
value is acceptable.  The constraints should tell the register allocator
where the value should go.  The paragraph you quoted is saying that the
operand predicate should restrict the value as much as possible to
ensure that the constraints will match.  The paragraph is not saying
that you should test the register class of a register in the operand
predicate.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Matching Constraints and Predicate
  2010-08-23 18:06 ` Ian Lance Taylor
@ 2010-08-24 13:36   ` Paulo J. Matos
  0 siblings, 0 replies; 3+ messages in thread
From: Paulo J. Matos @ 2010-08-24 13:36 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

On Mon, Aug 23, 2010 at 6:43 PM, Ian Lance Taylor <iant@google.com> wrote:
>
> This also makes no sense.  The operand predicate should test whether the
> value is acceptable.  The constraints should tell the register allocator
> where the value should go.  The paragraph you quoted is saying that the
> operand predicate should restrict the value as much as possible to
> ensure that the constraints will match.  The paragraph is not saying
> that you should test the register class of a register in the operand
> predicate.
>

Thanks for clearing this up.

-- 
PMatos

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-24  8:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-23 14:26 Matching Constraints and Predicate Paulo J. Matos
2010-08-23 18:06 ` Ian Lance Taylor
2010-08-24 13:36   ` Paulo J. Matos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).