public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tomasz Jankowski <tomcioj@gmail.com>
To: Ian Lance Taylor <iant@google.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Problem with modyfying "addsi3" in machine description
Date: Sun, 14 Oct 2012 19:29:00 -0000	[thread overview]
Message-ID: <CAMxYpJz_Oo_AwXMqA8LTXvqJ4qsKdnpRE60ctgupVX=emvSP2A@mail.gmail.com> (raw)
In-Reply-To: <CAKOQZ8xTdiv6A6M8HdfoPMAG8OUh6MZ_U-dRENqtJJx7Mp+atA@mail.gmail.com>

Thank you for answering your email.

I actually cannot use you suggestion, because source register and
destination register are almost always the same register. Now I'm
found something weird. Original template "addsi3" for OpenRISC is:

   (define_insn "addsi3"
     [(set (match_operand:SI 0 "register_operand" "=r,r")
       (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
   	 (match_operand:SI 2 "nonmemory_operand" "r,I")))]
    ""
    "@
     l.add   \t%0,%1,%2
     l.addi  \t%0,%1,%2"
    [(set_attr "type" "add,add")
     (set_attr "length" "1,1")])

and "mulsi3" is:

   (define_insn "mulsi3"
     [(set (match_operand:SI 0 "register_operand" "=r")
           (mult:SI (match_operand:SI 1 "register_operand" "r")
                    (match_operand:SI 2 "register_operand" "r")))]
     "TARGET_HARD_MUL"
     "l.mul   \t%0,%1,%2"
     [(set_attr "type" "mul")
      (set_attr "length" "1")])

Now, when I write in C such code:

   int b = 100;
   b *= 101;

GCC properly moves immediate to temporary register and then call
"l.mul" instruction. I tried to do the same trick and modified
"addsi3" template to:

   (define_insn "addsi3"
     [(set (match_operand:SI 0 "register_operand" "=r")
       (plus:SI (match_operand:SI 1 "register_operand" "%r")
   	 (match_operand:SI 2 "register_operand" "r")))]
    ""
    "l.add  \t%0,%1,%2"
    [(set_attr "type" "add")
     (set_attr "length" "1")])

The problem is that, GCC fails to compile with this modified template
with error:
   ../../gcc-4.5.1/gcc/crtstuff.c: In function ‘__do_global_dtors_aux’:
   ../../gcc-4.5.1/gcc/crtstuff.c:332:1: internal compiler error: in
gen_add2_insn, at optabs.c:4764

As I remember documentation for RTL says, that it's able to make
operands fit instruction template, so it's able to move immediate to
register as it's done for "multsi3". So why it doesn't work for
"addsi3"?

  reply	other threads:[~2012-10-14 11:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 15:05 Tomasz Jankowski
2012-10-12 17:16 ` Ian Lance Taylor
2012-10-14 19:29   ` Tomasz Jankowski [this message]
2012-10-14 20:33     ` Tomasz Jankowski
2012-10-14 23:19       ` Georg-Johann Lay
2012-10-15 11:56         ` Tomasz Jankowski
2012-10-15 15:37           ` Segher Boessenkool

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='CAMxYpJz_Oo_AwXMqA8LTXvqJ4qsKdnpRE60ctgupVX=emvSP2A@mail.gmail.com' \
    --to=tomcioj@gmail.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).