[RFC PATCH 8/9] [SH] Add splitter to addsi3_compact

Oleg Endo oleg.endo@t-online.de
Thu Jan 8 11:15:00 GMT 2015


On Thu, 2014-12-18 at 10:04 +0900, Kaz Kojima wrote:
> This patch is discussed in PR55212
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c65
> 
> and is to make LRA's register elimination work well on SH.
> The problem is SH has very limited add instructions only and expands
> rA := rB + N to (set rA (const_int N)) and (set rA (plus rA rB))
> instead of (set rA (plus rB (const_int N))).  It seems that the former
> combination isn't good for LRA's register elimination pass.  The patch
> adds splitter to addsi3_compact insn so that LRA can see the latter
> rtl.
> 
> --
> 	* config/sh/predicates.md (arith_or_int_operand): New predicate.
> 	* config/sh/sh.md (addsi3): Use arith_or_int_operand for operand 2.
> 	Return fail if operands[0] and operands[1] are overlap when
> 	operands[2] is integer constant.
> 	(*addsi3_compact): Make it define_insn_and_split which splits
> 	reg0 := reg1 + constant to reg0 = constant and reg0 := reg0 + reg1.

I've noticed that this change tends to produce code like ...
	mov	#123,rA
	...
	add	rA,rB

It's a bit better to do:
	mov	rB,rA
	...
	add	#123,rA

if the constant fits into #imm8.  The attached patch does that.
Tested with make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
and no new failures.  CSiBE shows a couple of cases where code size
decreases.  Committed as r219341.

Cheers,
Oleg

gcc/ChangeLog:
	PR target/55212
	* config/sh/sh.md (*addsi3_compact): Emit reg-reg copy instead of
	constant load if constant operand fits into I08.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sh_pr55212_addsi3_compact_2.patch
Type: text/x-patch
Size: 1255 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150108/0e72f08e/attachment.bin>


More information about the Gcc-patches mailing list