public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* approaches to carry-flag modelling in RTL
@ 2011-10-28 17:00 Peter Bigot
  2011-10-29 14:17 ` Richard Henderson
  0 siblings, 1 reply; 15+ messages in thread
From: Peter Bigot @ 2011-10-28 17:00 UTC (permalink / raw)
  To: gcc

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

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

end of thread, other threads:[~2012-02-07 22:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-28 17:00 approaches to carry-flag modelling in RTL Peter Bigot
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

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