[llvm-bugs] [Bug 52038] New: Missed loop vectorization with reduction and ptr load/store inside loop

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 2 03:07:00 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52038

            Bug ID: 52038
           Summary: Missed loop vectorization with reduction and ptr
                    load/store inside loop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

void test1(int *p, int *t, int N) {
    for (int i = 0; i != N; i++) *t += p[i];
}

void test2(int *p, int *t, int N) {
    if (N > 1024) // hint, N is not small
        for (int i = 0; i != N; i++) *t += p[i];
}

void test3(int *p, int *t, int N) {
    if (N > 1024) { // hint, N is not small
        int s = 0;
        for (int i = 0; i != N; i++) s += p[i];
        *t += s;
    }
}

test3 is successfully vectorized with LLVM, GCC, ICC. Sadly, only ICC can catch
test1 and test2.

https://godbolt.org/z/PzoYd4eEK

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211002/6ebd38a6/attachment.html>


More information about the llvm-bugs mailing list