https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123123
Bug ID: 123123
Summary: `a != 0 ? 1 : a + 1` is not always optimized to 1
Product: gcc
Version: 16.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
Blocks: 123122
Target Milestone: ---
Take The following gimple testcase
```
int __GIMPLE
g(int a)
{
int t;
int g;
int tt1;
bool b;
t = 1;
g = 0;
b = a != 0;
tt1 = a + 1;
t = b ? t : tt1;
return t;
}
```
This should just optimize to `return 1`.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123122
[Bug 123122] missed optimization for branch merging