Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	u1@terran.org, linux-mips@linux-mips.org
Subject: Re: MIPS checksum bug
Date: Sat, 20 Sep 2008 02:13:44 +0200	[thread overview]
Message-ID: <20080920001344.GC31314@linux-mips.org> (raw)
In-Reply-To: <Pine.LNX.4.55.0809191656030.29711@cliff.in.clinika.pl>

On Fri, Sep 19, 2008 at 05:09:17PM +0100, Maciej W. Rozycki wrote:

> > @@ -229,6 +239,9 @@ LEAF(csum_partial)
> >  
> >  	/* Still a full word to go  */
> >  	ulw	t1, (src)
> > +#ifdef USE_DOUBLE
> > +	add	t1, zero	/* clear upper 32bit */
> > +#endif
> >  	PTR_ADDIU	src, 4
> >  	ADDC(sum, t1)
> >  
> 
>  Unfortunately you can't zero-extend with a single instruction (you can
> use a single sll(v) to sign-extend), unless the R2 ISA provides some
> suitable oddity (which I haven't checked).  You want something like:
> 
> 	dsll32	t1, t1, 0
> 	dsrl32	t1, t1, 0
> 
> instead.

For a one's complement checksum it doesn't matter in which of the 4
halfwords the data ends is loaded.  So the easiest solution is:

	/* Still a full word to go  */
	ulw     t1, (src)
#ifdef USE_DOUBLE
	dsll	t1, t1, 32		/* clear lower 32bit */
#endif
	PTR_ADDIU       src, 4
	ADDC(sum, t1)

  Ralf

  parent reply	other threads:[~2008-09-20  0:13 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <072748C6-07A9-4167-A8A5-80D0F7D9C784@darkforest.org>
2008-09-17  5:15 ` MIPS checksum bug Bryan Phillippe
2008-09-17 10:40   ` Maciej W. Rozycki
2008-09-17 13:23     ` Atsushi Nemoto
2008-09-17 14:46       ` Maciej W. Rozycki
2008-09-17 15:27         ` Atsushi Nemoto
2008-09-17 18:21           ` Maciej W. Rozycki
2008-09-18 22:07             ` Ralf Baechle
2008-09-19 10:12               ` Maciej W. Rozycki
2008-09-19 11:23                 ` Ralf Baechle
2008-09-19 11:47                   ` [PATCH] MIPS checksum fix Ralf Baechle
2008-09-19 12:07                     ` Ralf Baechle
2008-09-19 12:15                       ` Maciej W. Rozycki
2008-09-19 14:09                       ` Atsushi Nemoto
2008-09-19 15:02                         ` Maciej W. Rozycki
2008-09-20 15:09                         ` Ralf Baechle
2008-09-23 21:52                       ` Bryan Phillippe
2008-09-23 22:06                         ` Ralf Baechle
2008-09-29 15:28                         ` Atsushi Nemoto
2008-09-19 12:26                   ` MIPS checksum bug Maciej W. Rozycki
2008-09-19 16:04                     ` Bryan Phillippe
2008-09-17 22:52       ` Bryan Phillippe
2008-09-18 16:17         ` Atsushi Nemoto
2008-09-19  1:14           ` Ralf Baechle
2008-09-19 15:43           ` Atsushi Nemoto
2008-09-19 16:09             ` Maciej W. Rozycki
2008-09-19 16:35               ` Thiemo Seufer
2008-09-19 23:18                 ` Maciej W. Rozycki
2008-09-20  0:13               ` Ralf Baechle [this message]
2008-09-20 13:45                 ` Atsushi Nemoto
2008-09-18  4:43     ` Bryan Phillippe
2008-09-18 10:06       ` Maciej W. Rozycki

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=20080920001344.GC31314@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@linux-mips.org \
    --cc=u1@terran.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