[PATCH] D144089: [IndVarSimplify] Transform the trip count to a simpler form
Tiehu Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 03:46:00 PST 2023
TiehuZhang created this revision.
TiehuZhang added reviewers: fhahn, dmgreen, sdesmalen, lebedev.ri.
Herald added subscribers: StephenFan, javed.absar, hiraditya.
Herald added a project: All.
TiehuZhang requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.
LoopVectorizer will create a loop guard based on the SCEV expression of ExitCount, and complex ExitCount will introduce redundant instructions. This patch simplifies the ExitCount by offsetting the trip count and induction variable so that there will be fewer redundant conditions after vectorization, e.g., llvm.smax.i64 as shown in test.
Before the optimization
int initial = 0;
for(int i = 0; i < nOut; i++) {
double temp_value = 0.0;
for (int j = initial; j < initial + nIn; j++) {
temp_value += values[j] * x[idx[j]];
}
initial += nIn;
b[i] = temp_value;
}
After the optimization
int initial = 0;
for(int i = 0; i < nOut; i++) {
double temp_value = 0.0;
for (int k = 0; k < nIn; k++) {
temp_value += values[k + initial] * x[idx[k + initial]];
}
initial += nIn;
b[i] = temp_value;
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144089
Files:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/test/Transforms/IndVarSimplify/simplify-tripcount.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144089.497625.patch
Type: text/x-patch
Size: 29126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230215/9440a000/attachment.bin>
More information about the llvm-commits
mailing list