From: Subash Abhinov Kasiviswanathan <subashab@codeaurora•org>
To: James Greenhalgh <james.greenhalgh@arm•com>,
Robin Murphy <robin.murphy@arm•com>
Cc: netdev@vger•kernel.org, davem@davemloft•net,
luke.starrett@broadcom•com, catalin.marinas@arm•com, nd@arm•com,
netdev-owner@vger•kernel.org
Subject: Re: [PATCH net-next] ipv6: Implement optimized IPv6 masked address comparison for ARM64
Date: Fri, 17 Mar 2017 15:20:06 -0600 [thread overview]
Message-ID: <a149df606bf5d9240b9e9eb2f6f6eace@codeaurora.org> (raw)
In-Reply-To: <20170317122252.GA32449@arm.com>
>
>> That's clearly not right - I'm not sure quite what undefined behaviour
>> assumption convinces GCC to optimise the whole thing away>
>
> While the pointer casting is a bit ghastly, I don't actually think that
> GCC is taking advantage of undefined behaviour here, rather it looks
> like
> you have a simple typo on line 3:
>
>> const __uint128_t *ul1 = (const __uint128_t *)a1;
>> const __uint128_t *ulm = (const __uint128_t *)m;
>> const __uint128_t *ul2 = (const __uint128_t *)a1;
>
> ul2 = a2, surely?
>
> As it is (stripping casts) you have a1 ^ a1, which will get you to 0
> pretty quickly. Fixing that up for you;
>
> bool
> ipv6_masked_addr_cmp_new(const struct in6_addr *a1, const struct
> in6_addr *m,
> const struct in6_addr *a2)
> {
> const __uint128_t *ul1 = (const __uint128_t *)a1;
> const __uint128_t *ulm = (const __uint128_t *)m;
> const __uint128_t *ul2 = (const __uint128_t *)a2;
>
> return !!((*ul1 ^ *ul2) & *ulm);
> }
>
> $ gcc -O2
>
> ipv6_masked_addr_cmp_new:
> ldp x4, x3, [x0]
> ldp x5, x2, [x2]
> ldp x0, x1, [x1]
> eor x4, x4, x5
> eor x2, x3, x2
> and x0, x0, x4
> and x1, x1, x2
> orr x0, x0, x1
> cmp x0, 0
> cset w0, ne
> ret
>
> Which at least looks like it might calculate something useful :-)
>
Hi Robin / James
Thanks for checking and sorry for the confusion. I'll retest this.
prev parent reply other threads:[~2017-03-17 21:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 4:42 [PATCH net-next] ipv6: Implement optimized IPv6 masked address comparison for ARM64 Subash Abhinov Kasiviswanathan
2017-03-17 12:00 ` Robin Murphy
2017-03-17 12:22 ` James Greenhalgh
2017-03-17 21:20 ` Subash Abhinov Kasiviswanathan [this message]
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=a149df606bf5d9240b9e9eb2f6f6eace@codeaurora.org \
--to=subashab@codeaurora$(echo .)org \
--cc=catalin.marinas@arm$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=james.greenhalgh@arm$(echo .)com \
--cc=luke.starrett@broadcom$(echo .)com \
--cc=nd@arm$(echo .)com \
--cc=netdev-owner@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=robin.murphy@arm$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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