https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77579

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|pinskia at gcc dot gnu.org         |unassigned at gcc dot 
gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Thinking about this some more, doing the multiply multiple times is actually
slower on most cores.
So this is not something you want to do normally but with a constant multiply
you do for small power of 2 constant.

E.g.:
```
void f(int x, int y, int z, int *s)
{
   int t = y * 2;
   s[0] = t + x;
   s[1] = x - t;
}
```
You should get:

        add     w2, w0, w1 lsl 1
        sub     w0, w0, w1 lsl 1
        stp     w2, w0, [x3]

And no seperate lsl instruction as the cost to do the lsl is free in this case.

Anyways I am not working on this any more.

Reply via email to