https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105832

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think the simple way of fixing this is optimizing:
```
bool f(int g)
{
return (1 >> g) != 0;
}
```
into
```
bool f0(int g)
{
return g == 0;
}
```

In threadfull1 (before vrp1) we have:
```
  <bb 5> [local count: 894749065]:
  if (iftmp.0_6 <= 1)
    goto <bb 6>; [41.00%]
  else
    goto <bb 8>; [59.00%]

  <bb 6> [local count: 366847113]:
  _3 = (int) iftmp.0_6;
  _4 = 1 >> _3;
  if (_4 == 0)
    goto <bb 7>; [50.00%]
  else
    goto <bb 8>; [50.00%]

  <bb 7> [local count: 183423557]:
  iftmp.1_12 = iftmp.0_6 << 1;

  <bb 8> [local count: 894749065]:
  # iftmp.1_7 = PHI <iftmp.1_12(7), iftmp.0_6(5), iftmp.0_6(6)>
```
if we optimize the bb6 to:
```
  if (iftmp.0_6 != 0)
    goto <bb 7>; [50.00%]
  else
    goto <bb 8>; [50.00%]
```
We should be able to ifcombine the 2 GIMPLE to just:
iftmp.0_6 != 0 && iftmp.0_6 <= 1

Which then will unswitch correctly ...

Reply via email to