https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126294
Bug ID: 126294
Summary: a*3/2 -> a + a/2 if a*3 is known not to overflow/wrap
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
unsigned f(unsigned short b)
{
unsigned t = b;
return t*3/2;
}
```
This could be done as `t+t/2` as we know t*3 does not overflow/wrap around.
LLVM does this optimization.
The same is true for signed (which LLVM does not do currently).