public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "mhauff@bigpond.net.au" <mhauff@bigpond.net.au>
To: gcc@gcc.gnu.org
Subject: Expanding an ADDSI3 into 2 x ADDHI3 does not work
Date: Wed, 15 Jun 2005 07:16:00 -0000	[thread overview]
Message-ID: <12211316.1118819765880.JavaMail.imail@web02sl> (raw)

I have a fictitious machine which has a word size of 8-bits but can handle 16-bit adds and 16-bit mov's.  I am trying to build the most efficient support for handling an addsi3 insn.  My problem is that if I try to split up the addsi3 insn into a couple of addhi3 insns (using a define_expand template) the compiler appears to ignore this declaration and proceeds to implement addsi3 as a bunch of addqi's along with some carry propogation rtx's.  i.e. the compiler defaults to the word size of the machine and I can't seem to override this.
I could allow it to go and create its big long list of addqi's etc and then use some insn combining method such as a peephole optimizer but this seems really inefficient to me - especially when I can explicitly state how a larger insn should be split.

If I use the following addsi3 template:
(define_insn "addsi3"
 [(set (match_operand:SI 0 "general_operand" "=g")
       (plus:SI (match_operand:SI 1 "general_operand" "g")
                (match_operand:SI 2 "general_operand" "g")))]
  ""
  "addsi3 %1 %2 %0	;(%1 plus %2)->%0" )

I can observe addsi being used in the assembly output of my test case.

If I use:
(define_expand "addsi"
 [(set (match_operand:SI 0 "general_operand" "=g")
       (plus:SI (match_operand:SI 1 "general_operand" "g")
                (match_operand:SI 2 "general_operand" "g")))]
  ""
  "{
  emit_insn (gen_addhi3 (custom_subword(operands[0], 0, SImode),
								 custom_subword(operands[1], 0, SImode),
								 custom_subword(operands[2], 0, SImode)));
	emit_insn (gen_addhi3 (custom_subword(operands[0], 1, SImode),
								 custom_subword(operands[1], 1, SImode),
								 custom_subword(operands[2], 1, SImode)));
	DONE; 
   }" )

the output becomes a mess of addqi, cmpqi, and branches.

Any help would be great.
Thanks
Marty

             reply	other threads:[~2005-06-15  7:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15  7:16 mhauff [this message]
2005-06-15 11:59 ` Paolo Bonzini
2005-06-16  8:05 ` Björn Haase

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=12211316.1118819765880.JavaMail.imail@web02sl \
    --to=mhauff@bigpond.net.au \
    --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).