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

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a patch which gets us to:
```
  short int b.2_1;
...
  b.2_1 = b;
  _2 = b.2_1 <= 0;
  _4 = (char) _2;
  f = _4;
  f.5_5 = (unsigned char) _2;
  _6 = f.5_5 << 4;
  e = _6;
  _19 = b.2_1 <= 0;
  _7 = (short int) _19;
  _21 = _7 << 4;
  if (b.2_1 == _21)

```
Which is closer.

```
int f(short b)
{
  auto _19 = b <= 0;
  auto _7 = (short int) _19;
  auto _21 = _7 << 4;
  return b == _21;
}
```
is just `return false;` as _21's range is `[0,4]` but it is only 0 when `b > 0`

And then maybe:
(simplify
 (eq:c @0 (rshift (convert (le @0 integer_zero_p)) INTEGER_CST@1))
 (if (wi::to_wide(@1) < element_precision (TREE_TYPE (@0)) - 1)
  ( { false_value; } ))

Is this worth this pattern, I don't know ...

Reply via email to