https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112542
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So disabling dominator opts (-fno-tree-dominator-opts) allows this to be
optimized.
It looks like DOM is causing the lose of the __builtin_unreachable .
Before DOM we had:
```
<bb 2> [local count: 1073741824]:
b.0_1 = b;
_2 = b.0_1 == 0;
_4 = (int) _2;
c = _4;
_16 = b.0_1 != 0;
_15 = _16 ? 1 : 2;
if (_15 == 2)
goto <bb 3>; [0.00%]
else
goto <bb 4>; [100.00%]
<bb 3> [count: 0]:
__builtin_unreachable ();
<bb 4> [local count: 1073741824]:
if (_4 == 0)
goto <bb 6>; [50.00%]
else
goto <bb 5>; [50.00%]
<bb 5> [local count: 536870912]:
foo ();
```
Which could have been cleaned up to just:
```
if (b.0_1 == 0)
goto <bb 3>; [0.00%]
else
goto <bb 4>; [100.00%]
<bb 3> [count: 0]:
__builtin_unreachable ();
<bb 4> [local count: 1073741824]:
if (b.0_1 != 0)
goto <bb 6>; [50.00%]
else
goto <bb 5>; [50.00%]
<bb 5> [local count: 536870912]:
foo ();
``