[llvm-dev] Why doesn't this loop get removed?

Riyaz Puthiyapurayil via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 17 10:53:52 PDT 2020


int f() {
    int A[100];
    for (int i = 0; i < 100; ++i)
        A[i] = i;
    return A[10];
}

Neither gcc nor clang eliminates the loop. Clang also blows up the code a bit by unrolling the loop. Why can't this loop and the array be eliminated and the function body turned into ret i32 10 ? Am I missing something?

/Riyaz



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200617/b68c2e7c/attachment.html>


More information about the llvm-dev mailing list