[llvm-bugs] [Bug 47671] New: missing loop unrolling and vectorization for loop with peeled branch

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 28 14:58:57 PDT 2020


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

            Bug ID: 47671
           Summary: missing loop unrolling and vectorization for loop with
                    peeled branch
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvm-bugs at lists.llvm.org

Testcase (x86_64):

int broken_sum(int *p, int *q) {
    bool first = true;
    int sum = 0;
    while (p != q) {
        if (!first) {
            sum += 2;
        }
        sum += *p;
        first = false;
        ++p;
    }
    return sum;
}

We peel off the first ('first == true') iteration, but don't unroll or
vectorize the resulting ('first == false') loop [https://godbolt.org/z/9chsMr].
However, if we create that same resulting loop by initializing 'first' to
'false', then we do unroll and vectorize the loop
[https://godbolt.org/z/588ovf].

There's also a potential regression from LLVM 10 to trunk here: under -mno-sse,
with 'first' initialized to 'false', we used to unroll the loop even though we
couldn't vectorize [https://godbolt.org/z/bovvE9], but LLVM trunk does not
unroll the loop under -mno-sse [https://godbolt.org/z/4h3x5b].

-- 
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/20200928/429a1b01/attachment.html>


More information about the llvm-bugs mailing list