public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* divmod pattern question
@ 2018-06-20  5:16 Paul Koning
  2018-06-20  5:31 ` Jeff Law
  2018-06-20  8:24 ` Andreas Schwab
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Koning @ 2018-06-20  5:16 UTC (permalink / raw)
  To: GCC Development

Gentlepeople,

I have a two-operand divide instruction that takes a double length dividend in a register pair, and produces the quotient in the first register and remainder in the second.

How do I write a divmod pattern for that?  The quotient is easy enough, I write a match_operand for that register and a matching constraint ("0") for the input dividend.  But what about the remainder?  The remainder appears in a register that isn't explicitly mentioned in the RTL (it's the regnum one higher than the quotient, or if you like, the second subreg of the input (dividend) register.

I can make it a define_expand that adds a move from the remainder register into a new register which is the output operand, and count on the optimizer to optimize away that move.  Is that the best answer?  The current "mod" pattern does that, and I could keep that approach.

	paul

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

end of thread, other threads:[~2018-06-20 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-20  5:16 divmod pattern question Paul Koning
2018-06-20  5:31 ` Jeff Law
2018-06-20 13:05   ` Paul Koning
2018-06-20  8:24 ` Andreas Schwab

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).