[PATCH] D151403: [LoopPeel] Peel iterations based on and, or conditions
Joshua Cao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 21:10:35 PDT 2023
caojoshua created this revision.
Herald added subscribers: hoy, zzheng, hiraditya.
Herald added a project: All.
caojoshua added reviewers: nikic, fhahn.
Herald added a subscriber: StephenFan.
caojoshua added a comment.
caojoshua published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch looks at ALL and/or's in the loop. In https://reviews.llvm.org/D151052, @nikic recommended that we only look at and/or's that are used by selects and branches. I think its beneficial to look at the ALL and/or's for the following reasons:
1. We can look at nested and/or's, which won't be used directly by branch/select.
2. We can look at and/or's used in other ways. For example, it can be passed to a function.
I have some examples in https://godbolt.org/z/WzE5P1jca.
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();
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151403
Files:
llvm/lib/Transforms/Utils/LoopPeel.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151403.525427.patch
Type: text/x-patch
Size: 21433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/920147b4/attachment.bin>
More information about the llvm-commits
mailing list