[Bug middle-end/67809] Empty pointer-chasing loops aren't optimized out

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 15 10:38:00 GMT 2019


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

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
clang doesn't optimize the corresponding C testcase

struct Foo {
      struct Foo *next;
};

void release(struct Foo *next) {
    struct Foo *tmp = 0;
    for (struct Foo *it = next; it; it = tmp) {
        tmp = it->next;
    }
}

which means it needs to have a way in the IL to annotate loops as
terminating.

Does the C++ rule apply to all cycles or just to "loops"?  (thinking
of goto, recursion, etc.)


More information about the Gcc-bugs mailing list