[llvm-bugs] [Bug 43910] New: Loop splitting based on monotonic condition between indvar and trip count

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 5 09:34:56 PST 2019


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

            Bug ID: 43910
           Summary: Loop splitting based on monotonic condition between
                    indvar and trip count
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

We could have something like:

void body();
void mainwork();
void remainder();

void bad(unsigned width) {
    for(int col = 0; col < width; ++col) {
        if(col >= (width - (width % 8))) // last 'width % 8' pixels.
            remainder();
        else
            mainwork();
        body();
    }
}

Currently that loop is left as-is.

But it could be split into something like this, thus removing conditional from
loop.

void body();
void mainwork();
void remainder();

void good(unsigned width) {
    for(int col = 0; col < (width - (width % 8)); ++col) {
        if(false /*col >= (width - (width % 8))*/) // last 'width % 8' pixels.
            remainder();
        else
            mainwork();
        body();
    }
    for(int col = (width - (width % 8)); col < width; ++col) {
        if(true /*col >= (width - (width % 8))*/) // last 'width % 8' pixels.
            remainder();
        else
            mainwork();
        body();
    }    
}


https://godbolt.org/z/SVWuJV

-- 
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/20191105/cd3c720e/attachment.html>


More information about the llvm-bugs mailing list