public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* addsi3 with set condition register
@ 2005-07-14 10:07 ibanez
  2005-07-14 14:09 ` David Edelsohn
  2005-07-14 17:44 ` Nathan Sidwell
  0 siblings, 2 replies; 3+ messages in thread
From: ibanez @ 2005-07-14 10:07 UTC (permalink / raw)
  To: gcc






I'm writing a gcc back-end for a new RISC.
This RISC has two kinds of add instructions,
one updates condition register and one doesn't.
ex.

1.)
   add     <-  add
   comp    <-  update condition register

2.)
   add_c   <-  add & update condition register

But case 2 pattern is not used at all.

The rtl generated by a sample program with -dr option is

  (insn 12 11 13 (set (reg:SI 168)
        (plus:SI (reg/v:SI 166 [ a ])
            (reg/v:SI 167 [ b ]))) -1 (nil)
    (nil))

  (insn 13 12 14 (set (reg:CC 33 cr1)
        (compare:CC (reg:SI 168)
            (const_int 0 [0x0]))) -1 (nil)
    (nil))
My pattern is

 (define_insn "..."
  [ (set (match_operand:SI 0 "register_operand" "=g")
       (plus:SI (match_operand:SI 1 "register_operand" "g")
              (match_operand:SI 2 "register_operand" "g")) )
    (set
        (reg:CC CC_REGNUM)
        (compare:CC (match_dup 0) (const_int 0)))]

Although I can use peephole/peephole2, but I think it's
not a good approach?
Thank you for your reading :)

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

* Re: addsi3 with set condition register
  2005-07-14 10:07 addsi3 with set condition register ibanez
@ 2005-07-14 14:09 ` David Edelsohn
  2005-07-14 17:44 ` Nathan Sidwell
  1 sibling, 0 replies; 3+ messages in thread
From: David Edelsohn @ 2005-07-14 14:09 UTC (permalink / raw)
  To: ibanez; +Cc: gcc

>>>>> ibanez  writes:

ibanez> 2.)
ibanez> add_c   <-  add & update condition register

ibanez> But case 2 pattern is not used at all.

ibanez> (define_insn "..."
ibanez> [ (set (match_operand:SI 0 "register_operand" "=g")
ibanez> (plus:SI (match_operand:SI 1 "register_operand" "g")
ibanez> (match_operand:SI 2 "register_operand" "g")) )
ibanez> (set
ibanez> (reg:CC CC_REGNUM)
ibanez> (compare:CC (match_dup 0) (const_int 0)))]

	Try listing the compare first.  Also, you might try listing the
compare register as a match_operand with a constraint for the CC register
instead of hard-coding the register.  See rs6000.md add<mode>3_internal2
and add<mode>3_internal3 patterns for examples.

David

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

* Re: addsi3 with set condition register
  2005-07-14 10:07 addsi3 with set condition register ibanez
  2005-07-14 14:09 ` David Edelsohn
@ 2005-07-14 17:44 ` Nathan Sidwell
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2005-07-14 17:44 UTC (permalink / raw)
  To: ibanez; +Cc: gcc

ibanez@sunplus.com wrote:

>   (insn 12 11 13 (set (reg:SI 168)
>         (plus:SI (reg/v:SI 166 [ a ])
>             (reg/v:SI 167 [ b ]))) -1 (nil)
>     (nil))
> 
>   (insn 13 12 14 (set (reg:CC 33 cr1)
>         (compare:CC (reg:SI 168)
>             (const_int 0 [0x0]))) -1 (nil)
>     (nil))
> My pattern is
> 
>  (define_insn "..."
>   [ (set (match_operand:SI 0 "register_operand" "=g")
>        (plus:SI (match_operand:SI 1 "register_operand" "g")
>               (match_operand:SI 2 "register_operand" "g")) )
>     (set
>         (reg:CC CC_REGNUM)
>         (compare:CC (match_dup 0) (const_int 0)))]

your pattern is not equivalent to the two instructions shown.  (the pattern is a 
parallel, the insns are a sequence)

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

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

end of thread, other threads:[~2005-07-14 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-14 10:07 addsi3 with set condition register ibanez
2005-07-14 14:09 ` David Edelsohn
2005-07-14 17:44 ` Nathan Sidwell

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