public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Petar Bajic" <petar.bajic@micronasnit.com>
To: "Ian Lance Taylor" <iant@google.com>
Cc: <gcc-help@gcc.gnu.org>
Subject: Re: adding movz to machine description
Date: Fri, 11 Aug 2006 12:07:00 -0000	[thread overview]
Message-ID: <014701c6bd2c$28876390$4900a8c0@niit.micronasnit.com> (raw)
In-Reply-To: <m3odvdiz2i.fsf@localhost.localdomain>

I finally made it work, these rules will successfully emit both movz and 
movn instructions.
Thank you for help.

(define_insn "movsicc_movz"
  [(set (match_operand:SI 0 "register_operand" "=d")
   (if_then_else:SI (eq (match_operand:SI 1 "register_operand" 
"d")(const_int 0))
    (match_operand:SI 2 "register_operand" "d")
    (match_dup 0) ))]
  ""
  "movz\\t%0,%2,%1"
  [(set_attr "type" "condmove")
   (set_attr "mode" "SI")])

(define_insn "movsicc_movn"
  [(set (match_operand:SI 0 "register_operand" "=d")
   (if_then_else:SI (ne (match_operand:SI 1 "register_operand" 
"d")(const_int 0))
    (match_operand:SI 2 "register_operand" "d")
    (match_dup 0) ))]
  ""
  "movn\\t%0,%2,%1"
  [(set_attr "type" "condmove")
   (set_attr "mode" "SI")])



(define_expand "movsicc"
    [(set (match_operand:SI 0 "register_operand" "=d")
     (if_then_else:SI
       (match_operator 1 "comparison_operator" [(match_operand:SI 4 
"register_operand" "d") (const_int 0)])
        (match_operand:SI 2 "register_operand" "d")
 (match_operand:SI 3 "register_operand" "d") ))]
  ""
  "
{
if (operands[2] != operands[0])
{
 emit_insn (gen_movsi (operands[0], operands[3]));
 if (GET_CODE(operands[1]) == EQ)
 {
    dlx_emit_cond_move_z(operands[0], operands[2], operands[3]);
    DONE;
   }
   else if (GET_CODE(operands[1]) == NE)
   {
    dlx_emit_cond_move_n(operands[0], operands[2], operands[3]);
    DONE;
   }
   else
    FAIL;
}
else
{
 if (GET_CODE(operands[1]) == NE)
 {
    dlx_emit_cond_move_z(operands[0], operands[3], operands[3]);
    DONE;
   }
   else if (GET_CODE(operands[1]) == EQ)
   {
    dlx_emit_cond_move_n(operands[0], operands[3], operands[3]);
    DONE;
   }
   else
    FAIL;
}
}")


(define_insn "movsicc_internal"
  [(set (match_operand:SI 0 "register_operand" "=j,j,j,j,j")
  (if_then_else:SI
  (match_operator 1 "comparison_operator" [(match_operand:SI 4 
"register_operand" "k,k,k,k,k") (const_int 0)])
  (match_operand:SI 2 "register_operand" "d,i,d,I,d")
  (match_operand:SI 3 "register_operand" "d,d,i,d,I")))]
  "(GET_CODE(operands[1]) == EQ)"
  "movz\\t%0,%2,%4\\n\\tmovn\\t%0,%3,%4"
  [(set_attr "type" "condmove")
   (set_attr "length" "2")
   (set_attr "mode" "SI")])


And in dlx.c functions dlx_emit_cond_move_n and dlx_emit_cond_move_z look 
like this:

int

dlx_emit_cond_move_z (rtx dest, rtx src1, rtx src2)

{

dlx_compare_op0 = force_reg(SImode, dlx_compare_op0);

emit_insn(gen_movsicc_movz(dest, dlx_compare_op0, src1));

}

int

dlx_emit_cond_move_n (rtx dest, rtx src1, rtx src2)

{

dlx_compare_op0 = force_reg(SImode, dlx_compare_op0);

emit_insn(gen_movsicc_movn(dest, dlx_compare_op0, src1));

}

best regards,
Petar Bajic

----- Original Message ----- 
From: "Ian Lance Taylor" <iant@google.com>
To: "Petar Bajic" <petar.bajic@micronasnit.com>
Cc: <gcc-help@gcc.gnu.org>
Sent: Tuesday, July 25, 2006 3:39 PM
Subject: Re: adding movz to machine description


> "Petar Bajic" <petar.bajic@micronasnit.com> writes:
>
>> > It may be correct for the pattern to not be matched with expand.  It's
>> > OK if the if-conversion pass picks it up, which seems to be what is
>> > happening for you.
>> >
>> > If the generated code you are getting is wrong, then problem is likely
>> > in the define_insn patterns somewhere.  They don't correct represent
>> > what the instruction does, or they don't correctly implement it.
>> >
>> > Ian
>>
>> After some modifications, I managed to make gcc use my define_expand -
>> I see it in debug.11.ce1 and following files, but then it disapears in
>> debug.17.combine, and in the end it does not appear in asm code. How
>> to find out what kills it? :)
>
> That means that the combine pass has replaced it with something else
> which is equivalent which the combine pass thought would be cheaper.
> Look at the generated RTL to see what it turned into.  If the
> resulting code is less efficient to run, then you need to adjust your
> costs (the TARGET_RTX_COSTS hook).
>
> Ian 

  parent reply	other threads:[~2006-08-11  9:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-21  9:55 Petar Bajic
2006-07-21 16:30 ` Ian Lance Taylor
2006-07-25 10:09   ` Petar Bajic
2006-07-25 13:39     ` Ian Lance Taylor
2006-07-25 14:10       ` Petar Bajic
2006-07-25 14:56         ` Ian Lance Taylor
2006-08-11 12:07       ` Petar Bajic [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-07-07 13:54 Help required for c to VCG GDL flow chart Sharad Pratap
2006-07-07 14:24 ` adding movz to machine description Petar Bajic
2006-07-07 17:39   ` Ian Lance Taylor
2006-07-12 11:10     ` Petar Bajic
2006-07-13  7:52       ` Ian Lance Taylor
2006-07-18 12:06         ` Petar Bajic
2006-07-18 14:35           ` Ian Lance Taylor
2006-07-25 18:25   ` Rask Ingemann Lambertsen

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='014701c6bd2c$28876390$4900a8c0@niit.micronasnit.com' \
    --to=petar.bajic@micronasnit.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=iant@google.com \
    /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).