From: Jose Abreu <jose.abreu@synopsys.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: David Laight <David.Laight@aculab.com>,
"open list:SYNOPSYS ARC ARCHITECTURE"
<linux-snps-arc@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Vineet Gupta <vineet.gupta1@synopsys.com>,
<alexey.brodkin@synopsys.com>,
Joao Pinto <joao.pinto@synopsys.com>,
"Vitor Soares" <vitor.soares@synopsys.com>
Subject: Re: [PATCH v2] ARC: io.h: Implement reads{x}()/writes{x}()
Date: Fri, 30 Nov 2018 08:56:53 +0000 [thread overview]
Message-ID: <57437493-31bb-eced-032c-1f54470b030e@synopsys.com> (raw)
In-Reply-To: <CAK8P3a2U3ft3crF2SiAuc=PQdDooEUaVAN9gQDyxsxvBn5+xRw@mail.gmail.com>
On 29-11-2018 21:20, Arnd Bergmann wrote:
> On Thu, Nov 29, 2018 at 5:14 PM Jose Abreu <jose.abreu@synopsys.com> wrote:
>
>> --->8--
>> static noinline void test_readsl(char *buf, int len)
>> {
>> readsl(0xdeadbeef, buf, len);
>> }
>> --->8---
>>
>> And the disassembly:
>> --->8---
>> 00000e88 <test_readsl>:
>> e88: breq.dr1,0,eac <0xeac> /* if (count) */
>> e8c: and r2,r0,3
>>
>> e90: mov_s lp_count,r1 /* r1 = count */
>> e92: brne r2,0,eb0 <0xeb0> /* if (bptr % ((t) / 8)) */
>>
>> e96: sub r0,r0,4
>> e9a: nop_s
>>
>> e9c: lp eac <0xeac> /* first loop */
>> ea0: ld r2,[0xdeadbeef]
>> ea8: st.a r2,[r0,4]
>> eac: j_s [blink]
>> eae: nop_s
>>
>> eb0: lp ed6 <0xed6> /* second loop */
>> eb4: ld r2,[0xdeadbeef]
>> ebc: lsr r5,r2,8
>> ec0: lsr r4,r2,16
>> ec4: lsr r3,r2,24
>> ec8: stb_s r2,[r0,0]
>> eca: stb r5,[r0,1]
>> ece: stb r4,[r0,2]
>> ed2: stb_s r3,[r0,3]
>> ed4: add_s r0,r0,4
>> ed6: j_s [blink]
>>
>> --->8---
>>
>> See how the if condition added in this version is checked in
>> <test_readsl+0xe92> and then it takes two different loops.
> This looks good to me. I wonder what the result is for CPUs
> that /do/ support unaligned accesses. Normally put_unaligned()
> should fall back to a simple store in that case, but I'm not
> sure it can fold the two stores back into one and skip the
> alignment check. Probably not worth overoptimizing for that
> case (the MMIO access latency should be much higher than
> anything you could gain here), but I'm still curious about
> how well our get/put_unaligned macros work.
Here is disassembly for an ARC CPU that supports unaligned accesses:
-->8---
00000d48 <test_readsl>:
d48: breq_s r1,0,28 /* if (count) */
d4a: tst r0,0x3
d4e: bne_s 32 /* if (bptr % ((t) / 8)) */
d50: ld r2,[0xdeadbeef] /* first loop */
d58: sub_s r1,r1,0x1
d5a: tst_s r1,r1
d5c: bne.d -12
d60: st.ab r2,[r0,4]
d64: dmb 0x1 /* common exit point */
d68: j_s [blink]
d6a: nop_s
d6c: ld r2,[0xdeadbeef] /* second loop */
d74: sub_s r1,r1,0x1
d76: tst_s r1,r1
d78: bne.d -12
d7c: st.ab r2,[r0,4]
d80: b_s -28 /* jmp to 0xd64 */
d82: nop_s
--->8---
Notice how first and second loop are exactly equal ...
Thanks and Best Regards,
Jose Miguel Abreu
>
> Arnd
next prev parent reply other threads:[~2018-11-30 8:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-29 14:29 Jose Abreu
2018-11-29 14:38 ` David Laight
2018-11-29 14:42 ` Jose Abreu
2018-11-29 16:13 ` Jose Abreu
2018-11-29 21:20 ` Arnd Bergmann
2018-11-30 8:56 ` Jose Abreu [this message]
2018-11-30 13:44 ` Arnd Bergmann
2018-11-30 13:57 ` David Laight
2018-11-30 19:00 ` Vineet Gupta
2018-12-03 10:10 ` David Laight
2018-12-03 17:31 ` Vineet Gupta
2018-11-29 21:16 ` Vineet Gupta
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=57437493-31bb-eced-032c-1f54470b030e@synopsys.com \
--to=jose.abreu@synopsys.com \
--cc=David.Laight@aculab.com \
--cc=alexey.brodkin@synopsys.com \
--cc=arnd@arndb.de \
--cc=joao.pinto@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=vineet.gupta1@synopsys.com \
--cc=vitor.soares@synopsys.com \
/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
all inboxes | Powered by JetHome®