[llvm-bugs] [Bug 43892] New: Two-loop-deep loop peeling? ("loop scalar remainder splitting")
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Nov 3 07:46:29 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=43892
Bug ID: 43892
Summary: Two-loop-deep loop peeling? ("loop scalar remainder
splitting")
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
This is indeed similar to scalarization of loop remainer.
Let's suppose we have a loop like: (can be written with a `break;` too)
void sink();
#define N 3
void bad(int width) {
for(int col = 0; col < width; col += N) {
int colsToRemaining = width - col;
int colsToFill = std::min(colsToRemaining, N);
for(int i = 0; i < colsToFill; ++i) {
// can't unroll/vectorize loop,
// variable ([1,N)) trip count
sink();
}
}
}
That std::min() conditional trip count is pretty unfortunate,
since in majority of cases colsToFill will be N.
It would be great to split the loop into something like
void good(int width) {
for(int col = 0; col < width; col += N) {
int colsToRemaining = width - col;
if(colsToRemaining >= N) {
for(int i = 0; i < N; ++i) // can unroll
sink(); // always runs N times
} else {
for(int i = 0; i < colsToRemaining; ++i) {
// can't unroll/vectorize loop,
// variable ([1,N)) trip count
sink();
}
}
}
}
That allows to unroll the first inner loop with constant trip count,
and may help with vectorization.
Should something like this be performed?
--
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/20191103/67e78ee6/attachment-0001.html>
More information about the llvm-bugs
mailing list