This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] AVR: implement HI/SI logic operations and sign/zero extension by define_insn_and_split ...
- From: Björn Haase <bjoern dot m dot haase at web dot de>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: Denis Chertykov <denisc at overta dot ru>,Andy Hutchinson <HutchinsonAndy at netscape dot net>,marekm at amelek dot gda dot pl,gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Apr 2005 07:11:49 +0200
- Subject: Re: [PATCH] AVR: implement HI/SI logic operations and sign/zero extension by define_insn_and_split ...
- References: <BE75F093.9B01%schlie@comcast.net>
> > My tests have shown that when using the splitters, code gets considerably
> > better for complex logic operations. For my real-world application of
> > 16k, I have observed about 50 bytes smaller code.
>
> - Do you suspect that most of these benefits would be preserved if for
> example both QI and HI mode operations were optimally coded, thereby both
> being able to preserved the visibility the few word (HI) mode operations
> the avr is capable of natively, and then correspondingly splitting SI/DI
> mode operations into them as required (as opposed to all the way to QI
> mode initially? given that C defaults to wanting to turn everything into
> int operations by default, which corresponds to HI mode on the avr?)
Hi,
the main benefit is, that expressions like
uint16_t a;
...
a |= 0xF503
a &= 0xFF00
will now yield two asm instructions, e.g.
ldi r24,0
ori r25,0xF5
i.e one move and one or RTL pattern instead of two ors and two ands. In order
to remove the |= 03 operation in above example, it was necessary to replace
(set (subreg:QI(reg:HI a) 0) (and:QI (subreg:QI(reg:HI a) 0) (const_int 0) )
by
(set (subreg:QI(reg:HI a) 0) (const_int 0)
. Seeing this in the RTL the compiler now recognizes that it is useless to
implement the previous "ori 03".
So it will help also when always using the appropriate type. It will be even
better, once one starts to split also arithmetics (sub, add, mul), moves and
shifts.
Yours,
Björn