Re: [LAD] Optimisations

From: Cedric Roux <sed@email-addr-hidden>
Date: Mon Aug 18 2014 - 20:17:51 EEST

On 08/18/2014 07:11 PM, Will Godfrey wrote:
> A long time ago ... in a land far away :)
> I did some assembler programming on the Acorn Archimedes (ARM 2/3) and worked
> out a series of additions and subtractions that would perform very fast
> multiplication of awkward numbers by known amounts.
>
> Is there any point in doing this for C programs, or are modern compilers
> sophisticated enough to do such things themselves?
>
> If anyone is interested *7 is:
> RSB R1, R0, R0, LSL #3
>

gcc 4.8 for ARM seems to give that instruction too with -O2 here for
a simple function that returns *7 of its input argument.

With no optimization:
00000000 <mul7>:
    0: e52db004 push {fp} ; (str fp, [sp, #-4]!)
    4: e28db000 add fp, sp, #0
    8: e24dd00c sub sp, sp, #12
    c: e50b0008 str r0, [fp, #-8]
   10: e51b2008 ldr r2, [fp, #-8]
   14: e1a03002 mov r3, r2
   18: e1a03183 lsl r3, r3, #3
   1c: e0623003 rsb r3, r2, r3
   20: e1a00003 mov r0, r3
   24: e24bd000 sub sp, fp, #0
   28: e49db004 pop {fp} ; (ldr fp, [sp], #4)
   2c: e12fff1e bx lr
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Tue Aug 19 00:15:01 2014

This archive was generated by hypermail 2.1.8 : Tue Aug 19 2014 - 00:15:01 EEST