From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Clubley Newsgroups: comp.lang.ada Subject: Re: Forcing GNAT to use 32-bit load/store instructions on ARM? Date: Fri, 11 Jul 2014 20:22:11 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <0e0b9ac2-e793-4cc5-8d8d-d3441ca28a58@googlegroups.com> <1j7b0m3yptffy$.1cztnkty8elrv$.dlg@40tude.net> Injection-Date: Fri, 11 Jul 2014 20:22:11 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e458ff8b81bc0c159989eb0e36c6e372"; logging-data="8002"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8Y/bU8hupEG1bJPIRMmJvynIkMkHfloU=" User-Agent: slrn/0.9.8.1 (VMS/Multinet) Cancel-Lock: sha1:sRwi1xab306dnr3WNwSHJ5x8qs4= Xref: news.eternal-september.org comp.lang.ada:20883 Date: 2014-07-11T20:22:11+00:00 List-Id: On 2014-07-11, Simon Wright wrote: > Simon Clubley writes: > >> On 2014-07-10, Simon Wright wrote: >>> Simon Wright writes: >>> >>>> The x86_64 code accesses all 32 bits of V. If it is more efficient on >>>> arm to access the relevant bytes for the component assignments, I >>>> expect that's what would happen (as reported). >>> >>> Just tried this on Raspberry Pi (GCC 4.6.3): yes, it only accesses the >>> relevant bytes. >> >> Just to make sure: you mean it uses ldrb/strb instead of ldr/str >> in the generated code ? > > Yes. I don't understand all the asm, but that part is clear! > > _ada_atom: > @ args = 0, pretend = 0, frame = 0 > @ frame_needed = 0, uses_anonymous_args = 0 > @ link register save eliminated. > ldr r2, .L2 > ldr r3, .L2+4 > ldmia r2, {r1, r2} > str r1, [r3, #0] > ldrb r1, [r3, #0] @ zero_extendqisi2 > bic r1, r1, #1 > strb r1, [r3, #0] > ldrb r1, [r3, #3] @ zero_extendqisi2 ^^^ Eeeek! :-) That's an "interesting" variant I have not seen before. It looks like gcc is generating code to do a byte offset load directly from the top byte of the 32-bit word. In my bitfield struct experiments in C I only ever saw gcc use ldrb when the bitfield was in the low 8 bits of the 32-bit word. I never managed to get gcc to do the above. Congratulations on finding yet another variant to this. :-) > bic r1, r1, #128 > strb r1, [r3, #3] > str r2, [r3, #0] > bx lr Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world