Re: [LAD] Bit shift

From: Jonathan Brickman <jeb@email-addr-hidden>
Date: Sun Mar 17 2019 - 18:56:40 EET

That is likely to change depending on GCC optimization setting, no?

J.E.B.

On Sat, Mar 16, 2019, 5:12 PM <karl@email-addr-hidden> wrote:

> Will Godfrey:
> > On Wed, 13 Mar 2019 00:09:17 +0100 (CET)
> > karl@email-addr-hidden wrote:
> >
> > >Will Godfrey:
> > >> Does anyone know if GCC will replace power of 2
> multiplications/divisions of
> > >> unsigned integers with bit shifts?
> ...
> > >$ cat a.c
> > >#include <stdint.h>
> > >
> > >int main(int argc, char *argv[]) {
> > > uint16_t b = argc * 2;
> > >
> > > return b;
> > >}
> > >$ gcc -S a.c
> ,,,
> > >It seems it just adds the value with itself here.
> ...
> > Thanks, that seems to hold true for a mixture of AMD and Intel machines.
>
> BTW, testing with 4, 8 and 16 instead of 2, it does actually do bit
> shifts:
>
> $ diff a.02.s a.04.s
> 16c16
> < addl %eax, %eax
> ---
> > sall $2, %eax
> $ diff a.02.s a.08.s
> 16c16
> < addl %eax, %eax
> ---
> > sall $3, %eax
> $ diff a.02.s a.16.s
> 16c16
> < addl %eax, %eax
> ---
> > sall $4, %eax
>
> Regards,
> /Karl Hammar
> _______________________________________________
> Linux-audio-dev mailing list
> Linux-audio-dev@email-addr-hidden
> https://lists.linuxaudio.org/listinfo/linux-audio-dev
>

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sun Mar 17 20:15:01 2019

This archive was generated by hypermail 2.1.8 : Sun Mar 17 2019 - 20:15:01 EET