public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Peter Bigot <bigotp@acm.org>
To: gcc@gcc.gnu.org
Subject: approaches to carry-flag modelling in RTL
Date: Fri, 28 Oct 2011 17:00:00 -0000	[thread overview]
Message-ID: <CAPOJ94N-6Ek4-s6RJXDLHUCTN3EssVuYnh8xTZaeQR-0_cE3Og@mail.gmail.com> (raw)

I'm rewriting a back-end originally based on AVR to eliminate insns for
multi-word operations (output templates like "add\;addc") and to use MODE_CC
instead of an unusual attribute-based approach.  The motivation is that I've
mostly found gcc does a better job than the existing back-end if it's shown
what's actually going on.

Part of this update requires correctly modelling the carry flag, for
plus/minus and for rotate through carry.  As noted in recent email here,
preserving the correct instruction order when expanding multi-word expressions
requires a set/use relation between the word-mode insns rather than a
simple clobber/use relation.

I've found several examples where back-ends model the carry in RTL.

Sparc does:

        (plus:SI
          (plus:SI
            (match_operand:SI 1 "arith_operand" "%r")
            (match_operand:SI 2 "arith_operand" "rI"))
          (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]

RX does:

        (plus:SI
          (plus:SI
            (ltu:SI (reg:CC CC_REG) (const_int 0))
            (match_operand:SI 1 "register_operand"  "%0,0,0,0,0,0"))
          (match_operand:SI   2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))

stormy16 does:

        (plus:HI
          (plus:HI
            (match_operand:HI 1 "register_operand" "%0,0,0")
            (zero_extend:HI (reg:BI CARRY_REG)))
          (match_operand:HI 2 "xs_hi_nonmemory_operand" "L,Ir,i")))

The variation points are:

(a) where the carry operand appears in the plus expressions;

(b) whether it's expressed as an ltu zero comparison or a zero_extend.

I'm inclined to follow sparc's lead, but is one or another of the choices
more likely to help combine/reload/etc do a better job?

Thanks.

Peter

             reply	other threads:[~2011-10-28 13:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28 17:00 Peter Bigot [this message]
2011-10-29 14:17 ` Richard Henderson
2011-10-29 17:34   ` Peter Bigot
2011-10-29 21:30     ` Richard Henderson
2011-10-29 22:22       ` Peter Bigot
2011-10-31 12:01         ` Paulo J. Matos
2011-10-31  9:39     ` Hans-Peter Nilsson
2011-10-31 12:35       ` Paulo J. Matos
2011-11-01  2:43         ` Hans-Peter Nilsson
2011-11-01 13:51           ` Paulo J. Matos
2011-11-01 21:59             ` Hans-Peter Nilsson
2011-11-02 20:03               ` Richard Henderson
2012-02-07 22:42                 ` Hans-Peter Nilsson
2011-10-31 14:58       ` Joern Rennecke
2011-10-31  9:40   ` Paulo J. Matos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPOJ94N-6Ek4-s6RJXDLHUCTN3EssVuYnh8xTZaeQR-0_cE3Og@mail.gmail.com \
    --to=bigotp@acm.org \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).