Does anyone know if GCC will replace power of 2 multiplications/divisions of
unsigned integers with bit shifts?
--
Will J Godfrey
http://www.musically.me.uk
Say you have a poem and I have a tune.
Exchange them and we can both have a poem, a tune, and a song.
__
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
int main(int argc, char *argv[]) {
uint16_t b = argc * 2;
return b;
}
$ gcc -S a.c
$ cat a.s
...
main:
.LFB0:
On Wed, 13 Mar 2019 00:09:17 +0100 (CET)
k...@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
>
>int main(int argc, char *argv[]) {
> uint16_t
Will Godfrey:
> On Wed, 13 Mar 2019 00:09:17 +0100 (CET)
> k...@aspodata.se 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
> >
> >int main(int argc, char *argv
That is likely to change depending on GCC optimization setting, no?
J.E.B.
On Sat, Mar 16, 2019, 5:12 PM wrote:
> Will Godfrey:
> > On Wed, 13 Mar 2019 00:09:17 +0100 (CET)
> > k...@aspodata.se wrote:
> >
> > >Will Godfrey:
> > >> Does anyone know if GCC will replace power of 2
> multiplication
J.E.B:
> That is likely to change depending on GCC optimization setting, no?
Then, why don't you just test it to find out, you have the means to
that after all.
Regards,
/Karl Hammar
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
On Sun, Mar 17, 2019 at 11:56:40AM -0500, Jonathan Brickman wrote:
> That is likely to change depending on GCC optimization setting, no?
>
This is why you can't trust very high level languages like C, and should
be wary of high-level languages like assembler.
--
Gordonjcp
__
On 3/17/19 5:56 PM, Jonathan Brickman wrote:
> That is likely to change depending on GCC optimization setting, no?
Not usually. It depends on the target architecture more than anything.
Even with -O0, gcc translates integer addition and multiplications into
a combination of bitwise and arithmetic
On Sun, 17 Mar 2019 20:12:04 +0100
Robin Gareus wrote:
>On 3/17/19 5:56 PM, Jonathan Brickman wrote:
>> That is likely to change depending on GCC optimization setting, no?
>
>Not usually. It depends on the target architecture more than anything.
>
>Even with -O0, gcc translates integer addition