[PATCH] D151052: [LoopUnroll] Peel iterations based on select, and, or conditions
Joshua Cao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 22 13:33:13 PDT 2023
caojoshua added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/LoopPeel.cpp:352
+ MaxPeelCount =
+ std::min((unsigned)SC->getAPInt().getZExtValue() - 1, MaxPeelCount);
+
----------------
nikic wrote:
> Why is this code needed now?
Latch branch conditions can peel the entire loop.
```
for (i = 0; i < 4; ++i) {
foo();
// The backedge branch, i < 4, is known for all iterations, and could make us peel the entire loop
}
```
When peeling only branch instructions, we avoid this by ignoring the branch condition of the latch block. But with this patch, we don't ignore and/or's that are used by the latch branch.
I will take out and/or's from this patch as recommended, but I would still like to keep this code block here. It's not breaking and it avoids unnecessary transformations.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151052/new/
https://reviews.llvm.org/D151052
More information about the llvm-commits
mailing list