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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
From:
```
//  char _6;
//  int _5;

  _5 = *i.3_4;
  _6 = (char) _5;
...

  _8 = (int) _6;
  if (_8 >= 0) // sign bit is not set
    goto <bb 5>; [59.00%]
  else
    goto <bb 4>; [41.00%]

  <bb 4> [local count: 220117072]:
  _19 = _6 & 1;
  if (_19 != 0)
    goto <bb 6>; [85.98%]
  else
    goto <bb 5>; [14.02%]

  <bb 5> [local count: 884494828]:

  <bb 6> [local count: 1073741824]:
  # iftmp.4_11 = PHI <1(4), 0(5)>
```


To
```
  _8 = (int) _6;
  _19 = _6 & 1;
  _22 = _21 & 2147483649;
  if (_22 == 2147483649)
    goto <bb 5>; [35.25%]
  else
    goto <bb 4>; [64.75%]

  <bb 4> [local count: 884494828]:

  <bb 5> [local count: 1073741824]:
  # iftmp.4_11 = PHI <1(3), 0(4)>
```

Ifcombine ignored the original truncation for the sign bit comparison ...

Reply via email to