public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hartmut Schirmer <hartmut.schirmer@arcormail.de>
To: gcc@gcc.gnu.org
Subject: SH code suboptimal
Date: Tue, 09 Jan 2001 10:58:00 -0000	[thread overview]
Message-ID: <01010919394504.00260@hallo> (raw)

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

                 reply	other threads:[~2001-01-09 10:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=01010919394504.00260@hallo \
    --to=hartmut.schirmer@arcormail.de \
    --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).