[PATCH] D112980: [LoopInfo] Fix a bug in the function getInductionVariable
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 4 06:20:12 PDT 2021
fhahn added a comment.
> The induction variable will be the first phi of the loop, and this does not match the logic of this function.
Is the code relying on the IV being the first phi in the loop? That is not a guarantee that can be relied on I think.
================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:312
- Instruction *StepInst = IndDesc.getInductionBinOp();
+ BasicBlock *Latch = this->getLoopLatch();
+ Value *StepInst = IndVar.getIncomingValueForBlock(Latch);
----------------
nit: no need for `this->`?
================
Comment at: llvm/unittests/Analysis/LoopInfoTest.cpp:1551
+
+TEST(LoopInfoTest, LoopInductionVariable) {
+ const char *ModuleStr =
----------------
Can you clean up the IR? There are multiple things that should not be needed, like
`"; Function Attrs:`
`dso_local sigext`
the metadata and more.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112980/new/
https://reviews.llvm.org/D112980
More information about the llvm-commits
mailing list