public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Expanding an ADDSI3 into 2 x ADDHI3 does not work
@ 2005-06-15  7:16 mhauff
  2005-06-15 11:59 ` Paolo Bonzini
  2005-06-16  8:05 ` Björn Haase
  0 siblings, 2 replies; 3+ messages in thread
From: mhauff @ 2005-06-15  7:16 UTC (permalink / raw)
  To: gcc

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

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

* Re: Expanding an ADDSI3 into 2 x ADDHI3 does not work
  2005-06-15  7:16 Expanding an ADDSI3 into 2 x ADDHI3 does not work mhauff
@ 2005-06-15 11:59 ` Paolo Bonzini
  2005-06-16  8:05 ` Björn Haase
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2005-06-15 11:59 UTC (permalink / raw)
  To: GCC Development, mhauff


> If I use:
> (define_expand "addsi"

addsi3

>   "{
>   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)));

How can this work?  You need something like an adchi3 pattern.

Paolo

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

* Re: Expanding an ADDSI3 into 2 x ADDHI3 does not work
  2005-06-15  7:16 Expanding an ADDSI3 into 2 x ADDHI3 does not work mhauff
  2005-06-15 11:59 ` Paolo Bonzini
@ 2005-06-16  8:05 ` Björn Haase
  1 sibling, 0 replies; 3+ messages in thread
From: Björn Haase @ 2005-06-16  8:05 UTC (permalink / raw)
  To: gcc; +Cc: mhauff

> 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.
Would it help to use (define_expand "addsi3" ...) instead of (define_expand 
"addsi" ...) ?

Yours,

Björn

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

end of thread, other threads:[~2005-06-16  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-15  7:16 Expanding an ADDSI3 into 2 x ADDHI3 does not work mhauff
2005-06-15 11:59 ` Paolo Bonzini
2005-06-16  8:05 ` Björn Haase

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