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

--- Comment #5 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Drea Pinski from comment #4) 
> So I don't think it is evrp which throws that away directly but rather
> group_case_labels_stmt.
> 
> I am testing a patch which removes that part. So mine for now.

The problem here is slightly different.
But still mine I think:
```
  # RANGE [irange] unsigned int [0, 3] MASK 0x3 VALUE 0x0
  _6 = (unsigned int) _1;
  # RANGE [irange] unsigned int [0, 2][+INF, +INF]
  _7 = _6 + 4294967295;
  if (_7 <= 2)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870912]:
<L8>:

  <bb 4> [local count: 1073741824]:
  # RANGE [irange] int [0, 3] MASK 0x3 VALUE 0x0
  # _2 = PHI <_1(3), 0(2)>
```
```
  # RANGE [irange] unsigned int [0, 2][+INF, +INF]
  _5 = _1 + 4294967295;
  if (_5 <= 2)
```
There is only one value _5 can't be for this to be true. that is `~0`.


The missed optimization is the same as this:
```
int unopt0(int v) {
    v&=3;
    if (v<=3 && v > 0)
      return v;
    return 0;
}

int unopt1(int v) {
    v&=3;
    unsigned vv = v;
    vv-=1;
    if (vv<=2)
      return v;
    return 0;
}
```

Reply via email to