[Bug tree-optimization/112659] missed-optimization: if (exp) return exp; else return 0;
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 21 22:14:57 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112659
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=19832
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>Note: this happens for all operators, not just addition!
Actually it is just addition with a constant on the trunk.
```
int g(int v, int b) {
if (v - b)
return v - b ;
else
return 0;
}
```
was handled with PR 19832.
I see division with a constant is not handled though:
```
int unopt(int v, int b) {
if (v /2)
return v / 2;
else
return 0;
}
```
More information about the Gcc-bugs
mailing list