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

--- Comment #5 from Jiangning Liu <jiangning.liu at amperecomputing dot com> ---
If we change "c3 = a" to "c3 = x->b", GCC can optimize it without IPA. It seems
VRP is working for this case.

$ cat tt7.c
#include <stdio.h>

int a;
typedef struct {
    int b;
    int count;
} XX;

int g;

__attribute__((noinline)) void f(XX *x)
{
    int c1 = 0;
    int c3 = x->b;
    if (x)
        c1 = x->count;
    for (int i=0; i<c1; i++) {
        if (c3 == x->count) {
            if (i > c3) {
                printf("Unreachable!");
                break;
            }
            else
                g = 2;
        } else
            g = i;
    }
}

void main(void)
{
    XX x;
    x.count = 100;
    a = 100;
    f(&x);
}

Reply via email to