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: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to