From: Herbert Xu <herbert@gondor.apana.org.au>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: linux-crypto@vger.kernel.org, "Jason A . Donenfeld" <Jason@zx2c4.com>
Subject: Re: [PATCH v2 2/2] crypto: algapi - annotate expected branch behavior in crypto_inc()
Date: Thu, 9 Mar 2017 18:46:34 +0800 [thread overview]
Message-ID: <20170309104634.GC7185@gondor.apana.org.au> (raw)
In-Reply-To: <1487109062-3419-2-git-send-email-ard.biesheuvel@linaro.org>
On Tue, Feb 14, 2017 at 09:51:02PM +0000, Ard Biesheuvel wrote:
> To prevent unnecessary branching, mark the exit condition of the
> primary loop as likely(), given that a carry in a 32-bit counter
> occurs very rarely.
>
> On arm64, the resulting code is emitted by GCC as
>
> 9a8: cmp w1, #0x3
> 9ac: add x3, x0, w1, uxtw
> 9b0: b.ls 9e0 <crypto_inc+0x38>
> 9b4: ldr w2, [x3,#-4]!
> 9b8: rev w2, w2
> 9bc: add w2, w2, #0x1
> 9c0: rev w4, w2
> 9c4: str w4, [x3]
> 9c8: cbz w2, 9d0 <crypto_inc+0x28>
> 9cc: ret
>
> where the two remaining branch conditions (one for size < 4 and one for
> the carry) are statically predicted as non-taken, resulting in optimal
> execution in the vast majority of cases.
>
> Also, replace the open coded alignment test with IS_ALIGNED().
>
> Cc: Jason A. Donenfeld <Jason@zx2c4.com>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2017-03-09 18:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 21:51 [PATCH v2 1/2] crypto: arm/aes-neonbs - resolve fallback cipher at runtime Ard Biesheuvel
2017-02-14 21:51 ` [PATCH v2 2/2] crypto: algapi - annotate expected branch behavior in crypto_inc() Ard Biesheuvel
2017-03-09 10:46 ` Herbert Xu [this message]
2017-03-09 10:46 ` [PATCH v2 1/2] crypto: arm/aes-neonbs - resolve fallback cipher at runtime 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=20170309104634.GC7185@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=Jason@zx2c4.com \
--cc=ard.biesheuvel@linaro.org \
--cc=linux-crypto@vger.kernel.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).