<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/77558>77558</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `x == 1 ? 1 : (x == -1 ? -1 : 0)` should be optimized to `((unsigned)t) + 1 <= 2 ? 0`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pinskia
      </td>
    </tr>
</table>

<pre>
    Take:
```
int f(int x)
{
  if (x == 1)
    return 1;
  if (x == -1)
    return -1;
  if (x == 0)
 return 0;
  return 0;
}
int g(int x)
{
  if (x == 1)
 return 1;
  if (x == -1)
    return -1;
  return 0;
}
```

These both should produce:
```
int h(int t)
{
  unsigned t1 = t;
  t1+=1;
  return t1<=2 ? t : 0;
}
```

But currently only f produces h which I find strange in itself
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU82OmzAQfprhMkpkjwmBA4ekCKn3fQFjDLjrQISH7qZPX0FIs22zq6paCWGwv7G-nxkdgmt7a3PYHWFXRHribhjzs-vDs9NRNdSX_Ek_W1AHEAWIAyRifZZf1zM2QOm8vgJlK2h_vH4gugaB0lcEVYAqUP7CICKOlqexRwnqPfzmYcHmgwpxL1jR4g34ry3YF3cl7f8p-RQZ7zP7w_Lr-6mzwWI1cIehGyZf43kc6sl8mFS36uNH-qZ-aYUaWc60kd-QYwl0BFU8IMwS1BdQBSGoEhlBHf5ZxHFiNNM42p79BYfeX7C56QjY4UvnTIdfsXF9jYFH3bcWXY-Og_VNVOeqzlSmI5vLvYjTJIkzGXV5XUuZNdSoWCZUxUbHhtJGmyZTWWYaEbmcBMVCSiESIZXcapMII1VCJlZG1wZiYU_a-a3330_bYWwjF8Jk8_1-t0sjryvrwzIyRL19weUQiOYJGvO5ZlNNbYBYeBc43G9hx97mkIh7Gy22ycW23ztmOdjI1VDKIBG3qCuLw5ndyf2Y4xpwtpVSoPSWIVA2Z4xAx-XuOSC8JjRnEE2jzzvmc5i7hUqgsnXcTdXWDCegcua7LpvzOHyzhoHKRWUAKhcXfgYAAP__-Rwhsg">