This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

SH code suboptimal


Hi,

compiling this file

---------------
# 1 "long.c"
extern unsigned long long ull1, ull2;
extern long long ll1, ll2;
# 18 "long.c"
void shift_R_u_2(void) { ull1 = (ull2) >> (2); }
---------------

with the 2001-01-08 snapshort gives the following output:

---------------
	.file	"long.c"
! GNU C version 2.97 20010108 (experimental) (sh-elf)
!	compiled by GNU C version 2.7.2.3.
! options passed:  -lang-c -D__GNUC__=2 -D__GNUC_MINOR__=97
! -D__GNUC_PATCHLEVEL__=0 -D__sh__ -D__ELF__ -D__sh__ -D__ELF__ -Acpu=sh
! -Amachine=sh -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Wall -D__sh1__ -O3 -Wall
! -fomit-frame-pointer -fschedule-insns -fverbose-asm
[..]
_shift_R_u_2:
	mov.l	.L3,r2
	mov.l	@r2,r5
	mov	r5,r3
	mov.l	@(4,r2),r6
	shll16	r3
	shlr2	r3
	shll16	r3
	mov	r6,r0                ! unneeded move
	shlr2	r0                   ! shlr2 r6
	mov	r3,r4                ! unneeded move
	or	r0,r4                ! or r6,r3
	mov.l	.L4,r0
	shlr2	r5
	mov.l	r5,@r0
	rts	
	mov.l	r4,@(4,r0)           ! mov.l r3,@(4,r0)
..L5:
	.align 2
..L3:
	.long	_ull2
..L4:
	.long	_ull1
[...]
---------------

which could save two moves and two registers

Hartmut

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]