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

--- Comment #3 from dcci <dccitaliano at gmail dot com> ---
Slightly easier example that still fails (no nested loop):

```
long patatino() {
    long x = 0;
    while (x < 10) {
            if (x % 2 == 0) {
                x += 2;
            } else {
                x += 1;
            }
            // Dead
            if ((x > 20) && (x % 5 == 0)) {
                x -= 5;
            }
            // Dead
            if ((x < -5) && (x % 3 == 0)) {
                x += 3;
            }
    }
    return x;
}
```

I am not an expert of GCC implementation but I would imagine some sort of range
analysis being able to find that the two conditions are dead and remove them
before unrolling. FWIW, LLVM seems to get this case right.

Reply via email to