linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Anton Blanchard <anton@ozlabs.org>
Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
	herbert@gondor.apana.org.au, davem@davemloft.net,
	linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH 2/2] crypto: powerpc: Add POWER8 optimised crc32c
Date: Mon, 4 Jul 2016 00:57:44 -0500	[thread overview]
Message-ID: <20160704055744.GA31609@gate.crashing.org> (raw)
In-Reply-To: <1467325185-21091-2-git-send-email-anton@ozlabs.org>

Hi Anton,

On Fri, Jul 01, 2016 at 08:19:45AM +1000, Anton Blanchard wrote:
> +#ifdef BYTESWAP_DATA
> +	addis	r3,r2,.byteswap_constant@toc@ha
> +	addi	r3,r3,.byteswap_constant@toc@l
> +
> +	lvx	byteswap,0,r3
> +	addi	r3,r3,16
> +#endif

You already have r0=0, so you can just do

	lvsr byteswap,0,r0
	vnot byteswap,byteswap

(the top bits of the permute vector bytes aren't used after all).

Or if you find that distasteful,

	lvsl byteswap,0,r0
	vspltisb v0,15
	vxor byteswap,byteswap,v0

Btw, the value in r3 isn't used after this, that last addi is useless?

> +	/*
> +	 * The reflected version of Barrett reduction. Instead of bit
> +	 * reflecting our data (which is expensive to do), we bit reflect our
> +	 * constants and our algorithm, which means the intermediate data in
> +	 * our vector registers goes from 0-63 instead of 63-0. We can reflect
> +	 * the algorithm because we don't carry in mod 2 arithmetic.
> +	 */

Expensive?  Ha!

	vgbbd v0,v0
	vperm v0,v0,v0,byteswap
	vgbbd v0,v0
	vperm v0,v0,v0,byteswap
	vsldoi v0,v0,v0,8

(or fold these last two together, needs another constant though).

> +	lvx	v0,0,r4
> +	lvx	v16,0,r3
> +	VPERM(v0,v0,v16,byteswap)
> +	vxor	v0,v0,v8	/* xor in initial value */
> +	VPMSUMW(v0,v0,v16)
> +	bdz	.Lv0

That VPERM looks strange...  You probably want v0 instead of v16.  Not
that it matters here.


Segher

  parent reply	other threads:[~2016-07-04  5:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 22:19 [PATCH 1/2] powerpc: define FUNC_START/FUNC_END Anton Blanchard
2016-06-30 22:19 ` [PATCH 2/2] crypto: powerpc: Add POWER8 optimised crc32c Anton Blanchard
2016-07-01  9:32   ` Herbert Xu
2016-07-04  5:57   ` Segher Boessenkool [this message]
2016-07-05 15:14   ` Herbert Xu

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=20160704055744.GA31609@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=anton@ozlabs.org \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.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 NNTP newsgroup(s).