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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the main difference after this patch:
Global Exported: c_11 = [irange] short int [-20409, -20409][1, 1] MASK 0xb046
VALUE 0xb047


vs before:
Global Exported: c_11 = [irange] short int [-INF, +INF] NONZERO 0xb047


That is we figure out c_11 will only either be -20409 [(short)45127] or 1 now.

That allows to get rid of if statement that leads to unreachable.
Which then allows unrolling to happen as the estimate for that loop is less.

Note the following testcase (which is fixed also on the trunk) was failing in
GCC 13:
```
void foo(void);
static int a, b;
int main() {
    {
        short c = 45127;
        int d;
        b = 0;
        for (; b <= 3; b++) {
            if (b) continue;
            d = 0;
            for (; d <= 127; d++) {
                if (!(((c) >= -20409) && ((c) <= 1))) {
                    __builtin_unreachable();
                }
                if (~(0 == a) & 1) return b;
                c = 0;
                for (; c <= 0; c++) a = 3;
            }
        }
        foo();
    }
}

```

The difference between this one and the original testcase is the # of
iterations of the loop. The same thing applies here; though I don't know what
caused the regression between GCC 12 and 13 for this one.

Reply via email to