On Wed, 13 Mar 2019 00:09:17 +0100 (CET)
karl@aspodata.se wrote:
>Will Godfrey:
>> Does anyone know if GCC will replace power of 2 multiplications/divisions of
>> unsigned integers with bit shifts?
>
>Test on your system:
>
>$ cat a.c
>#include <stdint.h>
>
>int main(int argc, char *argv[]) {
> uint16_t b = argc * 2;
>
> return b;
>}
>$ gcc -S a.c
>$ cat a.s
>...
>main:
>.LFB0:
> .cfi_startproc
> pushq %rbp
> .cfi_def_cfa_offset 16
> .cfi_offset 6, -16
> movq %rsp, %rbp
> .cfi_def_cfa_register 6
> movl %edi, -20(%rbp)
> movq %rsi, -32(%rbp)
> movl -20(%rbp), %eax
> addl %eax, %eax
> movw %ax, -2(%rbp)
> movzwl -2(%rbp), %eax
> popq %rbp
> .cfi_def_cfa 7, 8
> ret
> .cfi_endproc
>...
>$
>
>It seems it just adds the value with itself here.
>
>Regards,
>/Karl Hammar
Thanks, that seems to hold true for a mixture of AMD and Intel machines.
-- It wasn't me! (Well actually, it probably was) ... the hard part is not dodging what life throws at you, but trying to catch the good bits. _______________________________________________ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org https://lists.linuxaudio.org/listinfo/linux-audio-devReceived on Sun Mar 17 00:15:03 2019
This archive was generated by hypermail 2.1.8 : Sun Mar 17 2019 - 00:15:03 EET