[PATCH] D132443: [LSR] Fold terminal condition to other IV when possible
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 10:15:35 PDT 2022
craig.topper added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6613
+ return CantFold;
+ if (!cast<ICmpInst>(TermCond)->isEquality())
+ return CantFold;
----------------
Combine this if with the previous if
```
if (!isa<ICmpInst>(TermCond) || !cast<ICmpInst>(TermCond)->isEquality())
```
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6636
+ // *- Value Value --> used by terminal condition
+ std::function<bool(PHINode &)> IsToFold = [&](PHINode &PN) -> bool {
+ if (PN.getNumIncomingValues() != 2)
----------------
`std::function<bool(PHINode &)>` -> `auto`
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6639
+ return false;
+ Value *V = cast<Value>(&PN);
+
----------------
This cast is unecessary.
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6663
+ // replace the terminal condition
+ std::function<bool(PHINode &)> IsToHelpFold = [&](PHINode &PN) -> bool {
+ if (PN.getNumIncomingValues() != 2)
----------------
`std::function<bool(PHINode &)>` -> `auto`
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6669
+
+ for (unsigned I = 0; I < PN.getNumIncomingValues(); ++I) {
+ if (PN.getIncomingBlock(I) == LoopPreheader)
----------------
Can this use PN.getIncomingValueForBlock or getBasicBlockIndex?
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6699
+ continue;
+ if (!AddRec->isAffine())
+ continue;
----------------
Combine this with the previous if
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132443/new/
https://reviews.llvm.org/D132443
More information about the llvm-commits
mailing list