* [Bug target/77579] Missed multiple add (int) for CSEd case
[not found] <bug-77579-4@http.gcc.gnu.org/bugzilla/>
@ 2023-05-16 20:06 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: pinskia at gcc dot gnu.org @ 2023-05-16 20:06 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] only message in thread