[PATCH] D151052: [LoopUnroll] Peel iterations based on select, and, or conditions
Joshua Cao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 15:02:15 PDT 2023
caojoshua created this revision.
Herald added subscribers: hoy, zzheng, hiraditya.
Herald added a project: All.
caojoshua added reviewers: mkazantsev, fhahn, anna.
Herald added a subscriber: StephenFan.
caojoshua added a reviewer: nikic.
caojoshua updated this revision to Diff 524132.
caojoshua edited the summary of this revision.
caojoshua added a comment.
caojoshua updated this revision to Diff 524133.
caojoshua edited the summary of this revision.
caojoshua published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
More details examples in commit msg
caojoshua added a comment.
update commit msg
This allows us to peel this loop with a `and`:
for (int i = 0; i < N; ++i) {
if (i % 2 == 0 && i < 3) // can peel based on || as well
f1();
f2();
into:
for (int i = 0; i < 3; ++i) { // peel three iterations
if (i % 2 == 0)
f1();
f2();
}
for (int i = 3; i < N; ++i)
f2();
-----
This also allows us to peel loops with a `select`:
for (int i = 0; i <= N; ++i);
f3(i == 0 ? a : b); // select instruction
into:
f3(a); // peel one iteration
for (int i = 1; i <= N; ++i)
f3(b);
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151052
Files:
llvm/lib/Transforms/Utils/LoopPeel.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151052.524133.patch
Type: text/x-patch
Size: 26494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230521/01d2aec2/attachment.bin>
More information about the llvm-commits
mailing list