https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119471
Bug ID: 119471
Summary: (a * b) != 0 then we know that both a!=0 & b != 0
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Blocks: 85316, 110992
Target Milestone: ---
Take:
```
int fa(int a, int b)
{
int c = a * b;
if (c != 0)
return (a != 0);
return 0;
}
int fb(int a, int b)
{
int c = a * b;
if (c != 0)
return (b != 0);
return 0;
}
```
This should optimize to just `return (a*b) != 0` (well rather `a & b != 0` but
that is for a different issue). as we know if we multiply together 2 integers
then both of them has to be non-zero.
This is the missing optimization that is causing PR 110992 not to be optimized
any more after the `&-` -> `*` simplification.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110992
[Bug 110992] [13/14/15 Regression] missed VRP optimization due to
transformation of `a & -zero_one_valued_p` into `a * zero_one_valued_p`